unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* lexbind, global namespace prefixes, `byte-compile-defvar', and `custom-guess-name-alist'
@ 2011-01-12 21:00 MON KEY
  0 siblings, 0 replies; only message in thread
From: MON KEY @ 2011-01-12 21:00 UTC (permalink / raw)
  To: emacs-devel

It would be nice if `custom-guess-name-alist' recognized the
convention of naming global variables `*with-earmuffs*'.

I propose adding the following element:

 ("\\`\\*.*\\*\\'" variable)

In its current configuration the lexbind branch introduces new
treatmeant around declared special variables.

Specifically, there are these new symbols and primitives:
 `special-variable-p', `declared_special',
 `Vinternal_interpreter_environment',
 `Qinternal_interpreter_environment',

which affect (at least) the following symbols and primitives:

`defvar_per_buffer', `defvar', `defvaralias', `setq', `defconstant',
`let*', `let', `make-symbol', `funcall_lambda', etc.

Likewise, bzr revno: 101441 of 2010-09-15 in trunk says:

,----
|
| (byte-compile-file-form-defvar, byte-compile-defvar): Warn about
|  global vars which don't have a prefix and could hence affect lexical
|  scoping in unrelated files.
|
`----

The above change means that `byte-compile-defvar' now warns when

 (byte-compile-warning-enabled-p 'lexical)

returns non-nil and the symbol-name of a putatively special variable
does not match the regexp "[-*/:$]".

Currently this regexp is "optimized" under the assumption that if any
of the tokens "-" "*" "/" ":" "$" are present in a symbol-name then
that symbol is a potential global/dynamic var which does not lack a
prefix.

Given the warning issued and the regexp which triggers it, there seems
to be an implication that global "special variables" may be named
without a "namespace" so long as one or more magic tokens are present.
Indeed the warning even acknowledges certain lexical lisp conventions
of naming global/special variable symbols `*with-earmuffs*'.

Disregarding the (future) mechanisms by which one may declare a variable
special, there are perhaps unintended consesequence with the current
regexp in that where a symbol is named as `*earmuff', `/slashy',
`-dashy', `:colonic', `%fractured', it will regarded by the
byte-compiler as properly prefixed even though these aren't
file/library contexting namespaces...

As such, it might be be nice to see these pairs included of
`custom-guess-name-alist' as well:

 ("\\`[%$]"        function)  ;; `%private-fun', `$internal-fun'
 ("!\\'"           function)  ;; `set-foo!', `mutate-bar!'
 ("\\`\\+.*\\+\\'" variable)  ;; `+superior-lisp+', `+constant-name+'
 ("\\`-"           variable)  ;; `--some-var--', `-her-buddy-', `--his-pal'

The general thrust of these suggestions is that users should be
presented with a consistent interface to help with disambiguating
global variables in the lexbind esp. where there is potential for
introduction of confusion around local-variables, permanent-locals,
etc. which might otherwise go unnoticed, become difficult to
gain access to and/or become informed of.

--
/s_P\



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-12 21:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-12 21:00 lexbind, global namespace prefixes, `byte-compile-defvar', and `custom-guess-name-alist' MON KEY

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).