[closer-devel] Reflective Layer Activation in ContextL
Attila Lendvai
attila.lendvai at gmail.com
Thu Oct 19 22:03:08 UTC 2006
> 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...
>
as i understand subjects in slate they are a way for the user to override
very specific situations. just think of the subject being an implicit last
argument in a message send: with multiple dispatch this means that you can
override one single signature by specializing on the last implicit arg (the
subject), whereas with layers (first implicit arg) you can override an
entire bunch of methods.
both subject and layer are two contextual objects, but they can hook up on
MD in different ways.
i hope i'm making sense with this,
- attila
PS: i've just pushed ContextL integration for
defclass-star<http://common-lisp.net/project/defclass-star/>by
defining a deflayer*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/closer-devel/attachments/20061020/331288db/attachment.html>
More information about the closer-devel
mailing list