Trying to understand Class >> category

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

Trying to understand Class >> category

Mariano Martinez Peck
Hi guys. I need a category expert to explain why we have the following:

Class >> category
"Answer the system organization category for the receiver. First check whether the
category name stored in the ivar is still correct and only if this fails look it up
(latter is much more expensive)"

| result |
self basicCategory ifNotNil: [ :symbol |
((self environment organization listAtCategoryNamed: symbol) includes: self name)
ifTrue: [ ^symbol ] ].
self basicCategory: (result := self environment organization categoryOfElement: self name).
^result


So...how can a class store an "incorrect" category?  
Or in other words.... can

PackageInfo >> includesClass: aClass
^ self includesSystemCategory: aClass theNonMetaClass category

use #basicCategory (simple accessor) rather than #category? 

thanks,

--
Mariano
http://marianopeck.wordpress.com