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

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

Re: How do I pass a variable defined in a wrapping let, to a lambda?


From: Emanuel Berg
Subject: Re: How do I pass a variable defined in a wrapping let, to a lambda?
Date: Mon, 14 Mar 2022 15:51:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Jean Louis wrote:

> New `dlet' is this and it broke my programs because somebody
> removed `let*' inside. I don't think that person who changed
> it every used `dlet' in their own programs. Reason is
> semantics, "dlet" uses "let*" so they changed it, but did
> not provide "dlet*" (though is easy to adapt it).

So there is a `dlet', there is also a `lexical-let'

  lexical-let is a Lisp macro in ‘cl.el’.

  (lexical-let BINDINGS BODY)

  Like ‘let’, but lexically scoped.
  The main visible difference is that lambdas inside BODY will
  create lexical closures as in Common Lisp.

However ... I don't know how useful this is, especially not in
the face of `dlet' and even more so the consensus (?) that
static/lexical scope should be the default?

Also based on that the docstring is confusing since that's
what you get with `let' under static/lexical scope (at least
the closure example; I don't now if `lexical-let' is ALWAYS
static/lexical or if it allows already dynamic/special
variables just as `let' does even under static/lexical scope?
I think they are the same there as well, right?).

But/so better would be an `slet' (with an `llet' alias, or the
other way around) which is always static/lexical, a `dlet'
which is always dynamic/special, and a `let' that can be both
- static/lexical unless dynamic/special variable(s)
is/are already present with the same name(s) ...

`lexical-let' would be deprecated/obsolete which would be
stated in the docstring and by the byte-compiler, to not break
code one could alias it to `let' - not that I think think
people use it a lot, right?

Then static/lexical scope would be the default, ugly and
error-prone cookies with respect to this would be unnecessary
and all dynamic/special use would be explicit and much easier
to describe in docstrings on a function-by-function basis.

Use of dynamic/special scope would be reduced a lot since
a lot of today's use is probably due to either ignorance or
old habits of not using the cookie to set/get
static/lexical scope.

Problem solved!

Any questions?

PS. When the legendary African leader Patrice Lumumba held his
    speeches he always concluded with that question. And there
    were never any questions, because if anyone asked he was
    later beaten up by Lumumba supporters :)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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