[Top][All Lists]

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

Re: Lexical binding

From: Christian Ohler
Subject: Re: Lexical binding
Date: Mon, 04 Apr 2011 09:32:27 +1000

On 3/04/11 22:26, Juanma Barranquero wrote:
On Sun, Apr 3, 2011 at 14:05, Christian Ohler<address@hidden>  wrote:

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)

Yes, but it is less informative.

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)

And this is just ugly.

How about:

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

Anyway, the point is that (elisp) "Converting a package to use
lexical scoping" says:

      To silence byte-compiler warnings about unused variables, just use a
   variable name that start with an underscore, which the byte-compiler
   interpret as an indication that this is a variable known not to be used.

but this exception is quite less useful if assignments produce the
"variable `_x' not left unused" warning.

IIRC, Common Lisp distinguishes between (declare (ignore ...)) and (declare (ignorable ...)). The latter is useful for macros that introduce bindings that may or may not be used. This doesn't really help with `loop', though, since it shouldn't declare its bindings ignorable.

I guess Emacs Lisp's new underscore syntax is the equivalent of (declare (ignore ...)), with no way to (declare (ignorable ...)). If this is the case, then I agree it's not quite expressive enough, and requires idioms like the above (with many macros, not just `loop').


reply via email to

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