emacs-devel
[Top][All Lists]
Advanced

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

Re: Typo in defconst-1 and defvar-1 docstrings?


From: Stefan Monnier
Subject: Re: Typo in defconst-1 and defvar-1 docstrings?
Date: Thu, 06 Oct 2022 15:22:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> I was reading through the implementation of defconst-1, but was confused
> by the docstring that states:
>
>    More specifically behaves like (defvar SYM 'INITVALUE DOCSTRING).
                                     ^^^^^^

It says "defconst" for me (as it should).  Am I missing something?

> Isn't the point of defconst-1 as a functional variant of defconst,

It is.

> that SYM will evaluate to a symbol?

In the function the SYM received is already a symbol.

> And why should INITVALUE be quoted?

Because similarly in the function INITVALUE is really a *value*
(i.e. already evaluated), so in order for `defconst` to behave the same,
you need to quote it to prevent treating that value as an expression
that needs to be evaluated.

E.g. if INITVALUE is the list `(1 2 3)` and SYM is the symbol `hello`,
the equivalent is

    (defconst hello '(1 2 3))

and not

    (defconst 'hello (1 2 3))

which would signal an error because of the quoted symbol and because of
the call to the "function" 1.


        Stefan




reply via email to

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