emacs-devel
[Top][All Lists]
Advanced

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

Re: Lexical binding


From: Christian Ohler
Subject: Re: Lexical binding
Date: Sun, 03 Apr 2011 22:05:51 +1000

On 3/04/11 4:57, Juanma Barranquero wrote:
The original trouble with `loop' is that, in a loop like this one,
with destructuring

  (defsubst my--bs-file-width ()
    (- (window-width)
      (loop for (name width . rest) in bs-attributes-list
          if (numberp width) sum width)
       (bs--get-name-length)
       1))

`name' is just a placeholder (as it is rest). I'm interested just in
`width'. And there's no way to write that loop as is without warnings.

In loop destructuring, you can use nil for fields that you want to ignore:

     (loop for (nil width . nil) in bs-attributes-list
           if (numberp width) sum width)

If you want to keep the ignored fields named, you could do something like

     (loop for (name width . rest) in bs-attributes-list
           do (progn name rest) ; ignore
           if (numberp width) sum width)

Christian.



reply via email to

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