Re: Access to optimization qualities
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Wed, 23 Nov 2005 15:56:36 +0100
zellerin@xxxxxxxxx wrote:
Hello,
is it somehow possible to get at current settings of optimization qualities, probably at macro-expansion time? The aim is to expand to different code under different circumstances. Issue writeup http://www.lisp.org/HyperSpec/Issues/iss101-writeup.html seems to suggest that it could be *somehow* possible, but I do not see any portable (or even non-portable, for clisp) way how to do it. I pondered if it could be part of the environment, but that is implementation dependent anyway.
It is implementation dependent. There was an attempt in CLtL2 to define access operations for environment objects, but that didn't make it into the ANSI Common Lisp standard. It was only recently that Allegro Common Lisp has provided a (seemingly) complete solution for doing this.
Either your implementation supports some elements of the CLtL2 approach, or you should find ways to implement Allegro's approach.
I have implemented a workaround for ContextL in which I also wanted a macro to expand differently according to optimization settings. The basic idea is to introduce a symbol macro that describes your own optimization setting, for example like this:
(define-symbol-macro optimize-xyz nil)
This allows a user to specify that he/she wants a different setting for a particular region of code:
(symbol-macrolet ((optimize-xyz t)) ...)
Inside a macro you can access that information as follows:
(defmacro bla (... &environment env)
(let ((optimize-xyz (macroexpand 'optimize-xyz env)))
(if optimize-xyz
(do-this ...)
(do-that ...))))You can make this look nicer by providing your own macro for the user that expands into symbol-macrolet.
Pascal
-- My website: http://p-cos.net Closer to MOP & ContextL: http://common-lisp.net/project/closer/ .
- References:
- Access to optimization qualities
- From: zellerin@xxxxxxxxx
- Access to optimization qualities
- Prev by Date: Re: XML parsers for lisp
- Next by Date: Re: Indentation with print-object
- Previous by thread: Access to optimization qualities
- Next by thread: SLIME breaks when using UTF-8.
- Index(es):
Relevant Pages
|