emacs-devel
[Top][All Lists]
Advanced

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

Re: unused local variables


From: Stefan Monnier
Subject: Re: unused local variables
Date: Fri, 30 Nov 2007 10:10:31 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> Are you saying that in

>  (defun test ()
>    (if my-dynamic-var
>        "correct"
>      "erroneous"))

>  (let ((my-dynamic-var t))
>    (test))

> you would force my-dynamic-var to be `defvar'ed to avoid a warning in the let?

Yes.  And that's good.  E.g. if you want to compile this file with the
lexical-scoping version of Emacs that Miles has been working on, this
is indispensable.

BTW, in the above example, the byte-compiler already complains in the
`test' function, so it's not like it's going to make that big
a difference.

Also dynamic scoping is sufficiently odd and rarely used that it deserve
special mention in the code.  It's pretty common to mark it with
a comment.  And code is always better than a comment since it tends to
bitrot a bit less quickly.


        Stefan


PS: Another "unused var" warning which we should add (I don't have it
    in my lock hack yet, tho) is the one that notices when a `defvar'
    declares a variable which is not used in the file.




reply via email to

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