all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
To: rms@gnu.org
Cc: Dan Nicolaescu <dann@ics.uci.edu>,
	monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: optimizing defconst
Date: Mon, 29 Oct 2007 11:46:38 +0100	[thread overview]
Message-ID: <87fxzumc4x.fsf@kfs-lx.testafd.dk> (raw)
In-Reply-To: <E1ImIE9-00079L-I5@fencepost.gnu.org> (Richard Stallman's message of "Sun\, 28 Oct 2007 20\:11\:33 -0400")

Richard Stallman <rms@gnu.org> writes:

>     One can make the argument that we can also use the analogy with
>     defmacro. If a macro is redefined at run time, the compiled code does
>     not know about it. It's not far fetched to do the same about defconst.
>
> I don't want the compiler to optimize away defconst values.
> It is asking for trouble (and it is work we don't need to do).

What about an option to make a constant read-only, something like

(defconst ...
   :read-only t)

The C-code already checks that constants (e.g nil and t) are not
modified via SYMBOL_CONSTANT_P, so there is no extra work at the
C-level for such a change (except provide accessor functions
set-variable-read-only and variable-read-only for the "constant"
field of a variable).

Then the byte-compiler could check to see if a constant (or any
variable for that matter) is really read-only and optimize it away.

But I see that enable-multibyte-characters is marked as read-only -
not because it cannot change, but because we don't want users to
modify it directly.  

So to make the byte-compiler aware of such things, it may be necessary
to mark some constants as "are constant, but don't optimize away", e.g.:

(put 'enable-multibyte-characters 'bytecomp-dont-optimize)

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2007-10-29 10:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-27 17:47 optimizing defconst Dan Nicolaescu
2007-10-27 20:32 ` Stefan Monnier
2007-10-28  2:28   ` Dan Nicolaescu
2007-10-29  0:11     ` Richard Stallman
2007-10-29 10:46       ` Kim F. Storm [this message]
2007-10-29 11:08         ` Juanma Barranquero
2007-10-29 14:19         ` Johan Bockgård
2007-10-29 16:25           ` Davis Herring
2007-10-30  2:14         ` Richard Stallman
2007-10-27 20:44 ` John Paul Wallington
2007-10-27 21:17 ` Kim F. Storm

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fxzumc4x.fsf@kfs-lx.testafd.dk \
    --to=storm@cua.dk \
    --cc=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.