emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: optimizing defconst


From: Stefan Monnier
Subject: Re: optimizing defconst
Date: Sat, 27 Oct 2007 16:32:04 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> (defconst viper-xemacs-p (featurep 'xemacs))

> (defun foo()
>   (if viper-xemacs-p (error "Hmmmm")))

> Shouldn't `foo' be optimized to just do nothing? 

Can't do it: some code might do (setq viper-xemacs-p t) before calling
`foo'.  Such code might be flagged by the byte-compiler with a warning "setq
on a constant", but it's only a warning and it's not always caught.

We could change `defconst' so that it really defines constants (on which
`setq' fails) and then such an optimization might be acceptable, but this is
a non-trivial change.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]