emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Re: Is this a bug in while-let or do I missunderstand i


From: Alfred M. Szmidt
Subject: Re: [External] : Re: Is this a bug in while-let or do I missunderstand it?
Date: Sat, 09 Nov 2024 13:18:41 -0500

   I'm not saying no one should use, or Elisp
   shouldn't provide, if/and/when/while-let[*]
   thingies.  I'm just saying (1) I don't find
   them helpful, personally (I don't use them),
   and (more importantly) (2) if we provide them
   then their doc needs to be very specific about
   what _exactly_ they do, and when (if not also
   how).

Agreed.  I was looking of the usages of WHILE-LET in Emacs, and each
time it is used it is quite confusing.  For example this:

      (while-let ((b)
                  ((< b end))
                  (e (next-single-property-change (1+ b) 'erc--msg nil end)))
        (save-restriction
          (narrow-to-region b e)
          (funcall fn))
        (setq b e))


If the bindings are to be reevaluated on each iteration, shouldn't B
always be NIL, and that it would end up with (< NIL end) would be on
each iteration causing an error?

How can (< b end) even be a spec binding here -- shouldn't that be an
error?

The exapanded code looks like this:

(catch 'done39
  (while t
    (let* ((s (and t b))
           (s (and s (< b end)))
           (e (and s (next-single-property-change ... ... nil end))))
      (if e
          (progn
            (save-restriction (narrow-to-region b e) (funcall fn))
            (setq b e))
        (throw 'done39 nil)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]