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

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

Re: [External] : Re: Lexical vs. dynamic: small examples?


From: Stefan Monnier
Subject: Re: [External] : Re: Lexical vs. dynamic: small examples?
Date: Sun, 15 Aug 2021 18:44:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Emanuel Berg via Users list for the GNU Emacs text editor [2021-08-16 00:22:43] 
wrote:
> Lars Ingebrigtsen wrote:
>>> So the proposal/question is, instead one could have `let'
>>> _always_ be lexical, and one "with-variables-as" which
>>> would be what is now called "dynamic binding" with let.
>> These are `lexical-let' and `dlet' (in Emacs 28).
> Ha! Now you are telling...

Note that `lexical-let` is an old thing of the deprecated `cl.el`
library which let you have static scoping let-bindings before
`lexical-binding` existed.

When `lexical-binding` is not enabled it's still currently the only way
I know to get a statically scoped let-binding, but when
`lexical-binding` is enabled you can use:

    (defmacro slet (bindings &rest body)
      (unless lexical-binding
        (error "`slet' requires `lexical-binding' to be enabled"))
      `(funcall
         (lambda ,(mapcar #'car bindings)
           ,@body)
         ,@(mapcar #'cadr bindings)))

instead,


        Stefan




reply via email to

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