[closer-devel] Reflective Layer Activation in ContextL
Pascal Costanza
pc at p-cos.net
Thu Oct 19 18:14:04 UTC 2006
On 19 Oct 2006, at 19:54, Attila Lendvai wrote:
>
>> i was also doing some _very_ quick and dirty performance
>> measurements with the new metacopy and indeed there was no
>> significant difference between the simple and the contextl version.
>
> Good to know. It was more an accident that I happened to find a way
> to implement this efficiently, but I also think this is important
> for general acceptance.
>
> i'm sure you know much more about these, but maybe you have not
> heard of Slate. in vague terms it's a lisp with smalltalk syntax
> where the atoms are objects (with prototype based multiple
> dispatch) not cons cells. (the most important addition of slate is
> that you dynamically annotate any object, no matter who created it,
> which will be a very important feature of future systems imho)
>
> (before the bootstrepping) there was 'subjective dispatch' in it.
> there was an implicit first and last argument for each function
> call, where the first was called layer and the last was called
> subject. after the bootstrap it was temporarily dropped because it
> made the method chaching and inlining much more difficult.
> unfortunately since then slate is an abandoned project.
I am aware of Slate, and I am aware of its notion of subjective
dispatch. It's actually discussed in the related work sections of our
papers on ContextL. ;) Slate's model is very close to that of US, a
version of Self with subjective dispatch by David Ungar and Randall
Smith (that was never implemented, but described conceptually in a
very nice paper).
It's indeed the case that it's not obvious how to implement something
like subjective dispatch efficiently. I am very happy that I have
accidentally stumbled upon a way how to do it in CLOS - and it's
described in our paper "Efficient Layer Activation for Switching
Context-dependent Behavior."
> so why isn't there a 'subject' for contextl? not that i ever missed
> it, i'm just curious. and because of this feel free to send a short
> answer... :)
It took me some time to understand this as well. I have thought about
a way to integrate subjects in CLOS, but I couldn't find a good way
for doing this. I think that I never had even a rough idea how to
approach this. The reason, however, is very clear once you think
about this:
In CLOS, there are no message receivers, in the Smalltalk/Java sense
where messages are sent to objects. CLOS is based on generic
functions where each argument can contribute to method selection.
This means at the same time that in CLOS, there is no "natural"
sender of a message: The only natural caller of a generic function is
the generic function that contains that call. None of its arguments
can be considered a good subject (maybe the first argument according
to argument precedence order, but that's too arbitrary for my taste).
If you think harder about this, I think you can note that Common Lisp
already has a (functional equivalent of a) possible sender
representation: Dynamically scoped special variables can play that
role. If you want to indicate to a function that it has been called
from a certain context / from a certain subject, just bind a special
variable to the information that represents that context / subject,
and then the function can inspect it. If you additionally want the
context to influence method dispatch - well, that's what ContextL
does. ;)
This is all speculation, so take this with a grain of salt. It's
certainly possible that I haven't gotten this right yet. We are still
in an early stage of understanding our intuitions about context-
oriented programming...
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/closer-devel/attachments/20061019/776ddb29/attachment.html>
More information about the closer-devel
mailing list