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

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

Re: Effect of lexical binding upon function paramaters


From: Emanuel Berg
Subject: Re: Effect of lexical binding upon function paramaters
Date: Sat, 05 Nov 2022 16:32:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

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

>> What I can see from this test below, formal parameters
>> ("arguments" in standard information interchange) are
>> always dynamic under dynabound, and always static under
>> lexical
>
> Yup. Same holds for the var bound by `condition-case`.
> The binding constructs that can be "either/or" are `let` and
> `let*` (via `lexical-let` for the dynbound dialect and via
> `defvar` for the lexbound dialect).

For dynbound `let'/`let*' defaults to dynamic, just as it
defaults to lexical for lexbound.

However in the presence of another variable with the same
name, while `let'/`let*' can bind it to another value, it
doesn't change the lexical/dynamic status of the variable -
and this is the case for both dialects.

So how do you create a lexical binding under dynbound?
`lexical-let'. (See example last.) And a dynamic/special
variable under lexbound? `defvar'.

So is it all about what let/let* defaults to? Almost?

The other cases (formal parameters etc), should one consider
them being dynamic as just collateral damage from an
implementation policy detail which had to do with something
else or are there arguments (ha) for that as well?

(defun test-y ()
  y)

(let ((y 1))
  (test-y) ) ; works, y is dynamic

(lexical-let ((y 6))
  (let ((y 10))
    y ; 10 but ...
    (test-y) )) ; DNC in test-y, y is lexical

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




reply via email to

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