Slots in layers, was Re: [closer-devel] ContextL design question...

Pascal Costanza pc at p-cos.net
Tue Feb 28 21:06:01 UTC 2006


On 28 Feb 2006, at 20:48, Nick Bourner wrote:

> Thanks for that, I'll give it a try.
>
> Is the value of the slot global or can it be set on a per-thread basis
> like active layers? I was thinking that it could be a good way of
> carrying information for a particular activation of a layer. Say, for
> instance, a stream for a display layer to write to or something. Then
> you could have something like
>
> (with-active-layers ((some-layer :some-slot a-value) some-other-layer)
>    ...)
> or
> (ensure-active-layer (some-layer :some-slot a-value))
>
> rather than something like
>
> (let ((*some-special* a-value))
>   (with-active-layers (some-layer some-other-layer)
>     ....
>
> Not a whole lot different but I think it just expresses the intent
> slightly more clearly.

Now, that's a very neat idea, especially the syntax. And I think it  
should be possible to implement this in a relatively straightforward  
way.

> My guess is that because it's using an allocation of :class it's
> global - one value for all threads.

Currently, it is indeed the case that such a slot cannot be  
dynamically scoped. I will turn it into a potentially special slot,  
like in the special-classes. This will probably take a little time,  
so I hope you can live with the workarounds for the moment...

Thanks again,
Pascal

>
> Cheers,
> Nick
>
> On 2/28/06, Pascal Costanza <pc at p-cos.net> wrote:
>>
>
> <snip>
>
>> Ah, ok. You can already do this by using undocumented behavior. So
>> for examlpe, it should be possible to say this:
>>
>> (deflayer some-layer ()
>>    ((some-slot :initform 42 :allocation :class :reader some-slot)))
>>
>> ...and then access the slot like this:
>>
>> (some-slot (layer-prototype (find-layer 'some-layer)))
>>
>> [Untested!]
>>
>> My goal is to make this look less ugly, but the semantics will be
>> more or less the same. (This is all a side effect of the fact that
>> layers are internally implemented as classes.)
>>
>>> I still haven't completely thought through what we were talking  
>>> about
>>> at DLD, and for the most part, it may not be necessary now. But I'll
>>> try to come up with a concrete example.
>>
>> OK, would be nice. (But don't worry too much...)
>>
>>
>> Cheers,
>> Pascal
>>
>>>
>>> Cheers,
>>> Nick
>>>
>>>
>>> On 2/28/06, Pascal Costanza <pc at p-cos.net> wrote:
>>>>
>>>> On 27 Feb 2006, at 19:10, Nick Bourner wrote:
>>>>
>>>>> Hi Pascal,
>>>>>
>>>>> I have to agree with your opinion that the prototype-based
>>>>> approach is
>>>>> the one to go for. I think that  moving to a class-based approach
>>>>> adds
>>>>> far too much complexity for minimal or no real gain in  
>>>>> usefulness or
>>>>> expressiveness. In my opinion that would be unfortunate,  
>>>>> because for
>>>>> me one of the strengths of ContextL is that it provides a
>>>>> conceptually
>>>>> simple, but very powerful, abstraction that  can be used to  
>>>>> simplify
>>>>> the organisation and expression of application code. Making the
>>>>> abstraction more complex somewhat defeats the object - if  
>>>>> you're not
>>>>> careful you could wind up with application code that's as  
>>>>> complex as
>>>>> it would have been without the layering.
>>>>
>>>> Thanks a lot for your feedback!
>>>>
>>>>> BTW - is the code for slots in layers available? I could really  
>>>>> use
>>>>> that about now :-)
>>>>
>>>> Hmm, could you explain to me again what it is that you want here  
>>>> - I
>>>> only have a rough idea from our discussion at the Dynamic Languages
>>>> Day, but it would be helpful if you try to describe again what
>>>> problem you actually want to solve. I hope I can then find a
>>>> solution...
>>>>
>>>>
>>>> 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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>> --
>> Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
>> Vrije Universiteit Brussel, Programming Technology Lab
>> Pleinlaan 2, B-1050 Brussel, Belgium
>>
>>
>>
>>
>>
>

-- 
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