unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Emanuel Berg <moasenwood@zoho.eu>,
	"'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'"
	<help-gnu-emacs@gnu.org>
Subject: Re: Lexical vs. dynamic: small examples?
Date: Sun, 9 Jan 2022 17:40:33 +0000	[thread overview]
Message-ID: <SJ0PR10MB54882B8C44A1C867C6EA1E90F34F9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

> >> FWIW, I just wrote a tiny library, `dyna-show.el', that
> >> defines minor mode `dyna-show-mode', which highlights
> >> occurrences of "special" (aka dynamically
> >> scoped) variables.
> >>
> >> It just uses `special-variable-p', which is limited.
> >>
> >> From the attachment, you can see another limitation:
> >> occurrences of a function, e.g. `font-lock-mode', that has
> >> the same name as a dynamic variable are also highlighted.
> >
> > Thanks, it is very helpful for cosmetics of the code.
> 
> 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.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13769 bytes --]

             reply	other threads:[~2022-01-09 17:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 17:40 Drew Adams [this message]
2022-01-10 13:10 ` Lexical vs. dynamic: small examples? Emanuel Berg via Users list for the GNU Emacs text editor
  -- strict thread matches above, loose matches on Subject: below --
2021-08-14  3:34 Eduardo Ochs
2021-08-14  3:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14  4:12   ` Eduardo Ochs
2021-08-14  7:35 ` tomas
2021-08-14 16:00   ` Eduardo Ochs
2021-08-14 19:41     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 20:42     ` tomas
2021-08-14 19:31   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 20:31     ` tomas
2021-08-14 21:26       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 21:29         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 19:00 ` Gregory Heytings
2021-08-14 20:16   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 20:23     ` Gregory Heytings
2021-08-14 21:05       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 21:13         ` tomas
2021-08-14 21:28           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 20:41   ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB54882B8C44A1C867C6EA1E90F34F9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).