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: Emanuel Berg
Subject: Re: [External] : Re: Lexical vs. dynamic: small examples?
Date: Mon, 16 Aug 2021 02:43:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

>> Can't it be done with `lexical-let'?
>
> `lexical-let` is deprecated (and expands to ugly code, is
> less efficient than using `lexical-binding`, and makes
> debugging harder).

OK, gotcha.

> Note that I also consider not using `lexical-binding` as
> deprecated (tho this is not yet the official position of
> Emacs maintainers).

I know right?

BTW I've realized static vs. dynamic scope are the best terms.
The words are each others opposites but they are also the best
in terms of technology.

Static scope:

  (let ((x 1))                  
    .                        <- that's right! no 
    (when run-time-condition <- matter conditions or
      (take-a-long-detour) ) <- detours it's the
    . )                      <- same scope

Dynamic scope:

    (let ((x 1))                  
    .                        <- oh, no! x's scope now depends
    (when run-time-condition <- on run-time particulars which
      (take-a-long-detour) ) <- determine if it extends or
    . )                      <- not into the detour function

"Lexical" is intuitive with respect to the static scope but it
isn't as intuitive why the dynamic scope _isn't_ "lexical".
One has to think of the above to get there. But if one has to
think of the above, one might just stop at that and call
it dynamic.

"Special" is confusing, especially because global variables
behaves intuitively and dynamic `let' don't - and
they are all special!

The static vs. dynamic position of definition, does that
relate to how this is implemented (a new variable vs. a new
value pushed to the stack?) - but, since it works for the best
terms, i.e. static vs. dynamic scope, the more the merrier :)

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




reply via email to

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