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

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

Re: Another question about lambdas


From: Michael Heerdegen
Subject: Re: Another question about lambdas
Date: Sat, 10 Dec 2022 21:29:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

<tomas@tuxteam.de> writes:

> On Sat, Dec 10, 2022 at 06:23:38PM +0100, Michael Heerdegen wrote:
> > Hello,
> > 
> > My new question for today is:
> > 
> > What's the result of the following expression - and why?  Or maybe it is
> > invalid?
> > 
> > #+begin_src emacs-lisp
> >   (let* ((x 'l)
> >          (f (lambda () x))
> >          (x 'd))
> >     (funcall f))
> > #+end_src
>
> I had to look that up in the elisp manual, and I must admit
> I didn't find it very clear, but ultimately it says what will
> happen.

The shadowing is only one aspect of the exercise.  The question of the
return value is still not trivial.

> Scheme docs are typically clearer, by explaining (let* ...) in
> terms of nested (let ...). Perhaps that should go into the
> Elisp manual, what do people think?

+1.

I've skimmed over (info "(elisp) Local Variables").  Saying that `let*' is
equivalent to nested `let's would be helpful to understand the matter.

OTOH, shadowing is explained quite well.

Another thing that should be changed on that page is that it (still) says
that "The default scoping rule in Emacs Lisp is called “dynamic
scoping”" - that's not really true any more since *scratch* defaults to
lexical scoping.

Michael.




reply via email to

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