From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: Typo in defconst-1 and defvar-1 docstrings?
Date: Thu, 06 Oct 2022 15:22:26 -0400 [thread overview]
Message-ID: <jwva668u5gn.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87v8owlrjf.fsf@posteo.net> (Philip Kaludercic's message of "Thu, 06 Oct 2022 18:45:40 +0000")
> 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
next prev parent reply other threads:[~2022-10-06 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 18:45 Typo in defconst-1 and defvar-1 docstrings? Philip Kaludercic
2022-10-06 18:48 ` Philip Kaludercic
2022-10-06 20:06 ` Stefan Monnier
2022-10-06 19:22 ` Stefan Monnier [this message]
2022-10-06 19:48 ` Philip Kaludercic
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=jwva668u5gn.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=philipk@posteo.net \
/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.
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).