Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access to optimization qualities

1 view
Skip to first unread message

zell...@gmail.com

unread,
Nov 23, 2005, 9:26:11 AM11/23/05
to
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.


Regards,

Tomas Zellerin

Pascal Costanza

unread,
Nov 23, 2005, 9:56:36 AM11/23/05
to

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/

0 new messages