[squeak-dev] Class#category implementation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Class#category implementation

Thomas Kowark
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?

I would be very thankful for any hints.

Kind regards,

Thomas

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Class#category implementation

Bert Freudenberg

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 -



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Class#category implementation

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


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


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Class#category implementation

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


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Class#category implementation

Thomas Kowark
On Mar 10, 2009, at 5:15 PM, Bert Freudenberg wrote:

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

Sorry for the top-posting. I will pay more attention to the answering  
style in the future.

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

So while it is possible, it is still pretty unlikely to happen when  
developing let's say a regular web application and using only the  
System Browser in order to alter one's application classes? I just  
wasn't sure, if "regular" usage of Squeak as a development platform  
can make this cache become invalid.

Thomas

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Class#category implementation

Bert Freudenberg

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

> On Mar 10, 2009, at 5:15 PM, Bert Freudenberg wrote:
>
>> 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)
>
> Sorry for the top-posting. I will pay more attention to the  
> answering style in the future.
>
>> 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 -
>
> So while it is possible, it is still pretty unlikely to happen when  
> developing let's say a regular web application and using only the  
> System Browser in order to alter one's application classes? I just  
> wasn't sure, if "regular" usage of Squeak as a development platform  
> can make this cache become invalid.


It shouldn't. However, this cache was only added recently (in 3.9  
iirc) so there might be some software out there that does weird  
things. The check is cheap so better leave it in.

- Bert -