[alexandria-devel] [Spam] Re: [PATCH] lazy-evaluate the default value in ENSURE-GETHASH
Willem Broekema
metawilm at gmail.com
Wed Jan 4 14:39:27 UTC 2012
On Tue, Jan 3, 2012 at 3:25 PM, Ryan Davis <ryan at acceleration.net> wrote:
> I also recently learned about constantp and just got excited :).
Talking about constantp: it takes as arguments: form &optional environment.
Constantness can depend on the environment, e.g. if the form is (m)
and its definition is like:
(defmacro m (&environment env)
(if (foo-p env) :constant-form (non-constant-form)))
Therefore you should always pass on environment within macros, so instead of:
(defmacro ensure-gethash (key hash-table &optional default)
`(... ,(if (constantp default) ..)))
use:
(defmacro ensure-gethash (key hash-table &optional default &environment env)
`(... ,(if (constantp default env) ..)))
- Willem
More information about the alexandria-devel
mailing list