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

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

Re: [External] : Re: Lexical vs. dynamic: small examples?


From: Emanuel Berg
Subject: Re: [External] : Re: Lexical vs. dynamic: small examples?
Date: Thu, 26 Aug 2021 02:57:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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

> One example is the variable `pi` which holds the famous
> constant but we don't want (let ((pi (get-previous-interval
> x))) ...) to temporarily redefine `pi` to
> something unrelated.
>
> This example is obsolete, tho: you should use `float-pi`
> instead of `pi` to refer to the famous constant.

Right, but `float-pi' is defined with `defconst'.

Let's see what it says ...

  Define SYMBOL as a constant variable. This declares that
  neither programs nor users should ever change the value.
  This constancy is not actually enforced by Emacs Lisp, but
  SYMBOL is marked as a special variable so that it is never
  lexically bound.

It looks like this in float-sup.el:

  (defconst float-pi (* 4 (atan 1)) "The value of Pi (3.1415926...).")
  (with-suppressed-warnings ((lexical pi))
    (defconst pi float-pi
      "Obsolete since Emacs-23.3.  Use `float-pi' instead."))
  (internal-make-var-non-special 'pi)

So `pi' is explicitely made non-dynamic with
`internal-make-var-non-special'.

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




reply via email to

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