[Cuis] A few proposed is: additions

Juan Vuletich juan at jvuletich.org
Fri Jun 15 06:05:41 CDT 2012


Hi Phil,

I agree with what you say, so I snipped those parts (especially #is* in 
compatibility package(s), that deserves a separate thread), to focus on 
the implementation.

Phil (list) wrote:
> ...
>> The problem is that to access the whole collection, including those from superclasses, you need to create collections on each call. This is too expensive.
>>     
>
> Sorry I wasn't explicit: I was assuming that there would be a cvar that got lazy loaded (including the walk up the hierarchy) by #protocols on the first call. From the second call on, the performance difference would just be a check for membership in the collection vs. the existing conditional logic approach.  A further assumption was that the class initialization logic would set the cvar to nil to ensure that there was a way to force its regeneration.
>
> If you don't like the idea of creating per-override cvars, a centralized protocol dictionary (i.e. for classes with #is: overrides, the lookup would be performed and if it doesn't exist, populate it with what was returned from #protocols.) could be used instead.
>
> A third approach could be to leave #is: alone and keep the introspection capabilities separate from the test, but then protocol information exists in at least two places: in the current #is: logic as well as the collection-backed store (whether via individual #protocols or a centralized store)
>
> I think a fair question to ask is: does anyone else see value in what I'm proposing or is this something only I want?
>
>   
>>> If there's a better way to accomplish either what I'm looking for in my first answer or what I'm proposing here I'm open to it, this is just what I've come up with (likely without considering other valid scenarios or issues).
>>>
>>> ...
>>>       
>> Let's think of a better one, one that is fast and non- redundant.
>>     

Well, your first proposal here is indeed fast (especially if we use 
#pointsTo:) and non-redundant. An issue is the need to call #initialize 
when the collection changes. It would be nice if this was automatic, 
somehow. Forgetting to do it could mean rather hard to find bugs. The 
first thing that comes to my mind is to have a well known message that 
gets sent to any class when a method is compiled. Let's see... (goes to 
look in Cuis...) Hehehe. It is already there: #noteCompilationOf:meta: . 
We can just use this method to clear the variable (btw, it shouldn't be 
a classVar but a classInstVar, right?) if the protocols change.

Besides, it looks a bit complex, but it seems to me that the value is 
greater than the complexity, so I'd go for it. Mhh. We'd also do some 
space analysis. I guess we'd be using just a couple of kb of RAM, so 
it's not an issue, but we should measure anyway.

Cheers,
Juan Vuletich




More information about the Cuis mailing list