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

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

Re: Lexical vs. dynamic: small examples?


From: Emanuel Berg
Subject: Re: Lexical vs. dynamic: small examples?
Date: Mon, 10 Jan 2022 14:10:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Drew Adams wrote:

>> But here it also has a functional value. Or to be even more
>> precise, the functional value is also what is appealing,
>> since I think it started in that end.
>
> tl;dr:
> 1. It can be useful.  2. It's not foolproof.
> ___
>
> I guess you're referring to this (from the
> `dyna-show.el' Commentary)?
>
>  [I]f a function has the same name as a dynamic
>  variable, then its occurrences are also
>  highlighted, as if they were occurrences of
>  the variable.
>
> For example `font-lock-mode' is a variable as
> well as a function.  Both kinds of occurrences
> of that symbol are highlighted the same.
>
> Whether this is considered a feature or a
> limitation, the reason is that it requires no
> analysis of the code (which would anyway be
> problematic and limited) to determine how each
> occurrence is used.  
>
> The Commentary calls it out as a limitation.
> And the sentence above comes right after this
> additional caveat:
>
>   The simple built-in test `special-variable-p' is used.
>   That test is not 100% reliable. It doesn't respect vacuous
>   `defvar' sexps, which declare a variable to be special in
>   a given context, without assigning a value to the
>   variable. Instead, it uses `defvar',`defconst', and
>   `defcustom' sexps with a value arg present.

Well, yes, that's a good example, but actually the functional
gain starts with the programmer thinking "hey, what should it
be called?" - "obey tradition" (follow the convention) and
even at that point the harsh reality of a programmer gets
a little "bit" easier ;)

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




reply via email to

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