Traits vs interfaces and a trivial idea (was Re: Future of smalltalk (was Re: election details *PLEASE READ*))

Klaus D. Witzel klaus.witzel at cobss.com
Fri Feb 23 08:04:02 UTC 2007


Hi Andreas,
on Fri, 23 Feb 2007 08:52:52 +0100, you wrote:
> Göran Krampe wrote:
>> I would be more interested in "late" binding where I could do:
>>     someThingy respondsToProtocol: aProtocol
>>  ...where aProtocol is more or less just a bunch of selectors. The main
>> difference is of course that the class (or any of its superclasses) of
>> someThingy doesn't need to *declare* that it implements aProtocol - it
>> just has to actually do it. :)
>
> Funny you should mention this. I had the same idea a while ago but the  
> trouble is that you want a really, REALLY fast check (as fast as isFoo  
> effectively so that you can say: "true isA: Boolean" and be that the  
> speedy equivalent of "true isBoolean") and to do this you need some way  
> of caching the result effectively (and invalidate it as the class  
> changes). Alas, I could never come up with a scheme that was as fast as  
> I needed it to be (if you have any ideas, I'm all ears).

Here's the scheme that is as fast as I needed it to be:

during method lookup, treat aProtocol as the object you want to cache.

The rest follows immediately.

/Klaus

> Cheers,
>    - Andreas
>
>





More information about the Squeak-dev mailing list