[slime-devel] Re: compiling forms/regions/defuns with (optimize (debug 3) (speed 0) (safety 0))

Juho Snellman jsnell at iki.fi
Wed Nov 22 04:26:45 UTC 2006


<heller at common-lisp.net> wrote:
> * Marco Baringer [2006-11-21 18:57+0100] writes:
>
>> what do people think about a varient of slime-compile-defun which
>> wrapped the code in
>>
>> (locally 
>>   (declaim (optimize (speed 0) (safety 3) (debug 3)))
>>   , at form)
>>
>> i'd bind this to C-u C-c C-c (and C-u C-c C-k)
>>
>> good idea? bad idea?
>
> Bad idea, because it will mess up source code locations.
>
> Would something like 
>
>  (eval `(locally (declaim (optimize (speed 0) (safety 3) (debug 3)))
>                  (compile ,form)))
>
> do the right thing?

No. Declaim will apply the declarations into the global environment,
so any subsequent compilations would also be done using that
optimization policy. Wrapping a locally around the declamation will
not change that.

I'm afraid there's no portable way of restoring the optimization
policy back to its original state. CMUCL has an extension to
with-compilation-unit for this. In SBCL swank-compile-string could
bind sb-c::*policy*, proclaim the new policy, and only then do the
compile-file. I don't know about other implementations.

-- 
Juho Snellman




More information about the slime-devel mailing list