From: Nikolaj Schumacher <me@nschum.de>
To: pjb@informatimago.com (Pascal J. Bourguignon)
Cc: help-gnu-emacs@gnu.org
Subject: Re: Working with constansts
Date: Mon, 18 May 2009 12:55:50 +0200 [thread overview]
Message-ID: <m2d4a6ptmx.fsf@nschum.de> (raw)
In-Reply-To: <7ceiuuczad.fsf@pbourguignon.anevia.com> (Pascal J. Bourguignon's message of "Tue, 12 May 2009 13:54:02 +0200")
pjb@informatimago.com (Pascal J. Bourguignon) wrote:
>> And in fact, you can cast constness away in C++, so it really has
>> nothing to do with execution versus compile time. It's just a helper
>> for the developer to prevent side-effects.
>
> However, the C or C++ compilers are allowed to consider that the value
> of the constant won't change, so they may inline any number of copies
> they want.
Yes, I was thinking of const references... And in lisp, consts would
actually be references (maybe with the exception of numbers)
(defconst x '(foo . bar)
We've talked about (setq x 'foo) being illegal, but that would not
prevent (setcar x 'bar). And even if you prevent that, you can have:
(defvar y '(foo . bar)
(defconst x y)
Now the compiler cannot assume that y will not change, it's just a
reminder to the developer.
>> There really is no pressing requirement for the current behavior, the
>> run-time just doesn't verify it.
>
> Nothing would prevent emacs lisp to specify defconst in such a way the
> byte compiler could do the same. Only in the case of emacs it's more
> practical to change the value of the constant, because it means that
> you can modify your program without having to restart emacs, which is
> a good thing in the case of an editor/IDE/OS.
And nothing would prevent the byte-compiler (and eval-last-sexp) to have
special privileges for overriding consts in a live environment. (You
don't have to format a disk to reclaim write-protected files, either.)
Certainly, inconsistencies might appear, unless every function inlining
the value is also re-evaluated. But that's also the case with macros.
regards,
Nikolaj Schumacher
next prev parent reply other threads:[~2009-05-18 10:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-10 15:25 Working with constansts Decebal
2009-05-10 16:19 ` Pascal J. Bourguignon
2009-05-10 16:20 ` Richard Riley
2009-05-10 16:33 ` Pascal J. Bourguignon
2009-05-12 10:34 ` Nikolaj Schumacher
2009-05-10 17:02 ` Drew Adams
2009-05-10 17:28 ` Richard Riley
2009-05-11 7:39 ` Tassilo Horn
[not found] ` <mailman.6953.1241976532.31690.help-gnu-emacs@gnu.org>
2009-05-10 18:17 ` Pascal J. Bourguignon
2009-05-11 1:36 ` Richard Riley
2009-05-11 6:29 ` Pascal J. Bourguignon
2009-05-12 10:06 ` Nikolaj Schumacher
[not found] ` <mailman.7056.1242122790.31690.help-gnu-emacs@gnu.org>
2009-05-12 11:54 ` Pascal J. Bourguignon
2009-05-18 10:55 ` Nikolaj Schumacher [this message]
[not found] ` <7ceiuuczad.fsf@pbourguignon.informatimago.com>
[not found] ` <mailman.7379.1242644154.31690.help-gnu-emacs@gnu.org>
2009-05-18 12:20 ` Pascal J. Bourguignon
2009-05-18 19:19 ` Nikolaj Schumacher
2009-05-10 18:59 ` Barry Margolin
2009-05-11 1:38 ` Richard Riley
2009-05-12 9:44 ` Nikolaj Schumacher
[not found] ` <mailman.7052.1242121473.31690.help-gnu-emacs@gnu.org>
2009-05-12 11:43 ` Pascal J. Bourguignon
2009-05-13 4:59 ` Barry Margolin
2009-05-13 13:41 ` Ralf Wachinger
2009-05-13 21:23 ` Barry Margolin
2009-05-11 9:58 ` Thien-Thi Nguyen
[not found] ` <mailman.6988.1242036217.31690.help-gnu-emacs@gnu.org>
2009-05-12 1:31 ` Barry Margolin
2009-05-11 8:27 ` Decebal
2009-05-12 9:46 ` Nikolaj Schumacher
2009-05-10 16:31 ` Drew Adams
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=m2d4a6ptmx.fsf@nschum.de \
--to=me@nschum.de \
--cc=help-gnu-emacs@gnu.org \
--cc=pjb@informatimago.com \
/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.
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).