[squeak-dev] Class#category implementation

Bert Freudenberg bert at freudenbergs.de
Tue Mar 10 16:15:53 UTC 2009


A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
(on-topic comment at bottom)
> On Mar 10, 2009, at 4:51 PM, Bert Freudenberg wrote:
>
>> On 10.03.2009, at 16:34, Thomas Kowark wrote:
>>
>>> Hi,
>>>
>>> Today I stumbled upon the implementation of the category method in  
>>> Class. It performs a lookup to check whether the name stored in  
>>> the instance variable is still correct. I have performed some  
>>> tests, changed the category names back and forth, and it always  
>>> was correct. So what is the purpose of this kind of  
>>> implementation? When can a category name change without the  
>>> instance variable being set to the same value?
>>
>> Classes are put into categories by the SystemOrganizer. This  
>> instance variable is just a cache, because looking up the category  
>> in the organizer is slow. The implementation ensures the cache is  
>> valid.
>>
>> - Bert -


On 10.03.2009, at 17:04, Thomas Kowark wrote:

> Thanks for the quick response. However, I still am wondering when  
> this cache could be invalid?
> Is it possible to change the category without the 'category'  
> instance variable of class being set to the new value as well?
>
> Thomas


There are few things in Squeak that are impossible ;)

Classes are just objects. I can modify the category instance variable  
for example. Or, I can modify SystemOrganization without informing the  
class. I can swap the identity of two classes. Etc.

- Bert -




More information about the Squeak-dev mailing list