emacs-devel
[Top][All Lists]
Advanced

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

Re: Lexical binding


From: Stefan Monnier
Subject: Re: Lexical binding
Date: Mon, 04 Apr 2011 17:44:30 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> Check the `dolist' macro, it has a FIXME for that.
> OK, fair enough. Sorry for the noise.
> Is this one also documented (or has a logical explanation that I'm
> again missing)?

No, it's not documented tho it's the same underlying problem:

> ;; test.el  -*- lexical-binding: t -*-
> (condition-case test
>     (ignore)
>   (quit test)
>   (error test))
> ;; end

> No error. Now, if you remove `test' in either handler:

Right.  Internally, the condition-case above is turned into

  (condition-case :fun-body
      (lambda () (ignore))
    (quit (lambda (test) test))
    (error (lambda (test) test)))

I.e. the underlying problem (shared with dolist and some pcase
situations as well) is that one binding occurrence of a variable (above,
`test') is turned into 2 or more, so you can get warnings about an
unused variable because some of the its binders aren't used, but since
it really corresponds to a single binder in the source code the
programmer can't really fix it, hence the warning is an annoyance.

I'm not sure yet how best to solve the issue.  The main problem is
that this warning is important to help convert programs from dynamic to
lexical scoping, so it's an important tool and hence shouldn't be silenced
too lightheartedly.


        Stefan



reply via email to

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