help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: sending function arguments to recursive function calls


From: Dmitry Gutov
Subject: Re: sending function arguments to recursive function calls
Date: Fri, 17 May 2013 16:26:09 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Gauthier Östervall <gauthier@ostervall.se> writes:

> On Mon, May 13, 2013 at 4:55 PM, Stefan Monnier
> <monnier@iro.umontreal.ca> wrote:
>> That's the question that the byte-compiler can't answer: maybe they
>> really weren't used (so you can remove them), or maybe they were used
>> elsewhere via dynamic scoping (in which case you need to add a (defvar
>> <var>) to force the use of dynamic scoping for this variable).
>
> All the variables that the byte-compiler complained about were defined
> in the first parameter of a let or a let* expression.
>
> My understanding of let and let* is that the first parameter defines
> local variables to be used in the second parameter (or later in the
> first parameter in the case of let*).
>
> The unused variables I had to remove were not referenced in the last
> parameter of the let or let* (nor later in the first parameter of
> let*), so I assumed they were not used anywhere.
>
> Is there a way that such variables may be used elsewhere (via dynamic
> scoping)? If yes, how?
> Couldn't it be the case only if they were defined with setq (so called
> free variables)?

This is the ugly side of dynamic scoping.

(defun foo ()
  (let ((bar 42))
    (baz)))

(defun baz ()
  bar)

(foo) ; => 42

baz ; => void-variable error



reply via email to

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