[closer-devel] with-special-initargs, etc.
Pascal Costanza
pc at p-cos.net
Sun Mar 5 12:42:02 UTC 2006
Hi,
OK, there is a new version of ContextL in the darcs repository with
the following extensions:
- with-special-initargs allows you to rebind slots in objects via
initargs. The syntax looks as follows:
(with-special-initargs ((object1 :initarg1 value1 :initarg2 value2)
(object2 :initarg3 value3 :initarg4 value4))
... body ...)
All the objects, initargs and values are in evaluated positions.
Initialization goes through shared-initialize so that you can do
further customizations.
There is also a with-special-initargs*:
(with-special-initargs* ((object1 ...)
(object2 ...))
... body ...)
The difference is that in with-special-initargs, the objects,
initargs and values are evaluated before any rebinding is performed,
while in with-special-initargs*, first object1 is reinitialized with
dynamic scoped, then object2, and so forth.
- with-active-layers is extended accordingly. If you only specify
layer names, then it works as before:
(with-active-layers (a b c)
...)
However, you can also specify initargs to rebind slots in layers with
dynamic scope:
(with-active-layers ((a :initarg1 value1) b (c :initarg2 value2))
...)
This expands roughly to:
(with-active-layers (a b c)
(with-special-initargs (((find-layer 'a) :initarg1 value1)
((find-layer 'c) :initarg2 value2))
...))
There is also a with-active-layers* that expands to a similar form
but with with-special-initargs* accordingly.
I haven't tested these extensions extensively, but I am pretty sure
that they should work correctly.
This includes the fact that initargs that are valid for multiple
slots will also rebind all of the corresponding slots. Only slots
that are :special will ever be rebound by the extensions above.
Currently, I don't signal any warnings or errors if an initarg (also)
corresponds to a slot that is not special - such a slot is simply
left out. Please let me know if you prefer to see an error in this case.
Cheers,
Pascal
--
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium
More information about the closer-devel
mailing list