GNU bug report logs - #58513
describe-function should say that defconst variables are constant

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Fri, 14 Oct 2022 12:05:02 UTC

Severity: wishlist

Full log


Message #47 received at 58513 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: rms <at> gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: psainty <at> orcon.net.nz, monnier <at> iro.umontreal.ca, 58513 <at> debbugs.gnu.org
Subject: Re: bug#58513: describe-function should say that defconst variables
 are constant
Date: Mon, 17 Oct 2022 05:41:09 +0000
Richard Stallman <rms <at> gnu.org> writes:

> defconst has had a subtle meaning: "It is ok to expect, in certain
> limited ways, that the value will not be altered."  Nothing more.

To my mind, the meaning is not subtle.  On the contrary, it is both
clear and well-documented.

The manual (info "(elisp) Defining Variables") explains:

    [defconst] defines SYMBOL as a value and initializes it.  It informs
    a person reading your code that SYMBOL has a standard global value,
    established here, that should not be changed by the user or by other
    programs.

From where I'm standing, this means that there is no practical
difference between a defconst and a defvar that Lisp code can rely on.

So, to give a somewhat contrived example, you can still break any
mathematical calculation in Emacs with:

    (setq float-pi 9)

The only way to not have your code break in the face of that is to
copy-paste the literal 3.141592... everywhere.




This bug report was last modified 2 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.