emacs-devel
[Top][All Lists]
Advanced

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

e and pi


From: Stefan Monnier
Subject: e and pi
Date: Thu, 16 Sep 2010 15:25:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

As you may have noticed, I have added a new warning to the byte-compiler
for defvars of variables that don't have a prefix.  This is in
preparation for the introduction of lexical scoping: in order not to
have to rewrite all the code, the lexbind branch uses `let' both for
dynamically-scoped let-bindings and for lexically-scoped let-bindings;
where the distinction is based on whether or not a variable has
been defvar'd.  This is the same system as used in Common-Lisp and it
works well in practice, but it requires a bit of care, because every
defvar has a global effect: it declares that this variable will use
dynamic-scoping wherever it gets let-bound.  So if a file uses `len' as
a lexically-scoped variable and another file does a (defvar len), we get
a conflict that results in the first file being evaluated with
a different semantic than expected by the author.

So, the end result is that (defvar <prefix>-<foo>) is OK because the
"<prefix>-" ensures you only mess with your own variable, but (defvar
<foo>) is not OK because you may interfere with some other package.

Now, we have a lot of offending (defvar <foo>) in Emacs currently, so we
will want to fix them, and to get things started, we want to fix the two
predefined float constants `e' and `pi'.

In their case, the solution is to rename them to `float-e' and
`float-pi', but this introduces a backward incompatibility.
I figure we could define-obsolete-variable-alias (which leaves the
problem of `e' and `pi' being dynamically scoped, but hopefully only
for a few versions until we remove the obsolete name), but this means
that every code that does (let ((e <foo>)) ...) would now get a stupid
warning about using an obsolete variable `e'.

So I intend to do the following:
- in Emacs-23.3, define `e', `float-e', `pi', and `float-pi' and declare
  `e' and `pi' obsolete, but without a make-obsolete-variable
  (i.e. only in NEWS and in docstrings).
- in Emacs-24 keep float-e and float-pi but get rid of `e' and `pi'.

Can anyone think of a better solution?


        Stefan



reply via email to

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