[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#58513: describe-function should say that defconst variables are cons
From: |
Stefan Monnier |
Subject: |
bug#58513: describe-function should say that defconst variables are constant |
Date: |
Fri, 14 Oct 2022 12:44:01 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Lars Ingebrigtsen [2022-10-14 16:25:30] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 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`.
>
> Hm... do you know if there's a performance impact from doing this?
In terms of memory use, we already use 2 bits for that `enum
symbol_trapped_write`, so adding a new value doesn't cost anything
at all.
In terms of run-time, it adds a 4th branch to a few 3-branch `switch`
statements, so it can have a performance impact, most importantly in
`set_internal`, I guess, but I'd be very surprised if it's ever not lost
in the noise:
- it only affects `setq` on global/dynamic vars which should be a small
fraction of the overall `setq` we perform nowadays.
- since that new branch always signals an error (well, in my own code,
that is: I don't know what that branch would end up doing on `master`
where we'd want to be more careful about backward compatibility), it's
expected to be more-or-less never taken and even the most naive branch
predictors should handle it "perfectly".
Stefan
- bug#58513: describe-function should say that defconst variables are constant, Stefan Kangas, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Phil Sainty, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Stefan Kangas, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Stefan Monnier, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/14
- bug#58513: describe-function should say that defconst variables are constant,
Stefan Monnier <=
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/15
- bug#58513: describe-function should say that defconst variables are constant, Richard Stallman, 2022/10/16
- bug#58513: describe-function should say that defconst variables are constant, Drew Adams, 2022/10/16
- bug#58513: describe-function should say that defconst variables are constant, Stefan Kangas, 2022/10/17
- bug#58513: describe-function should say that defconst variables are constant, Lars Ingebrigtsen, 2022/10/17
- bug#58513: describe-function should say that defconst variables are constant, Stefan Kangas, 2022/10/15
- bug#58513: describe-function should say that defconst variables are constant, Stefan Monnier, 2022/10/15