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 #23 received at 58513 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, Stefan Kangas <stefan <at> marxist.se>,
 58513 <at> debbugs.gnu.org
Subject: Re: bug#58513: describe-function should say that defconst variables
 are constant
Date: Fri, 14 Oct 2022 09:34:00 -0400
>> Yes, incurring a run-time cost doesn't sound worth it, but we could
>> perhaps make the byte-compiler warn about it.

The byte-compiler already does warn about it, but only if the assignment
is in the same file as the `defconst`.

FWIW, my own local Emacs has `defconst` create actually
constant variables by adding a `SYMBOL_DEFCONST` to `enum
symbol_trapped_write`.  Admittedly I didn't make them really constant:
I allow a subsequent `defconst` to change the value set by a previous
`defconst`, but `setq` signals an error just like it does if you try to
`setq` on `enable-multibyte-characters` or on `nil`.

I didn't bother exporting this info to `describe-variable` (and the
byte-compiler) but it would be easy to do.


        Stefan





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.