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: Sun, 11 Dec 2022 01:00:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hello Arash,

it seems you didn't notice that you participated in a quiz!

> > 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

> With lexical or with dynamic binding?

"With lexical or with dynamic binding?" is the correct answer to the
question.

Yes, the result depends on whether the expression is evaluated with
lexical binding or with dynamic.  The symbol names intended to give a
discrete hint (maybe too discrete).

So if we did not have the variable `lexical-binding' to check whether
lexical binding is used for evaluation, you could use a test like this:

#+begin_src emacs-lisp
(let* ((lb t)
       (getlex (lambda () lb))
       (lb nil))
  (funcall getlex))
#+end_src

I'm sorry that this was again a type "trap" question (everybody in the
trap can come out again now).

Michael.




reply via email to

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