2014-02-28 4:55 GMT-03:00 Diego Lont <diego.lont(a)delware.nl>nl>:
Hi Esteban,
I "solved" this problem by creating a template object. This template is created
once, for all classes and when I need a "description of the class", I ask the
for description of the template.
I guess you mean one template instance per class/hierarchy.
Do you have a class instance variable for this template instance?
But you are right: most descriptions are static and
could be defined on the class side. Allowing them to be defined on both class side and
instance side might be a good idea. And this would allow you to ask for the description on
the class side as well. And when you ask the description of a concrete object, it
get's enriched with the instance side descriptions.
Exactly.
Dolphin Smalltalk has its own meta descriptions (named
"AspectDescriptors" or simply "aspects") that provide specific
inspectors and other nice features for its inspectors and toolset.
On Object's instance side the #publishedAspects is implemented as:
Object>>#publishedAspects
"Answer a <LookupTable> of the <Aspect>s published by the
receiver."
| aspects |
aspects := self class publishedAspectsOfInstances.
...
^aspects
And in the class side:
Object class>>#publishedAspectsOfInstances
"Answer a LookupTable of AspectDescriptors that describe the aspects published
by an instance of the receiver. Overridden by subclasses to add the aspects
published locally."
^(LookupTable new)
add: (self newInstanceAspect: #yourself class: Aspect);
yourself
CompiledCode class>>#publishedAspectsOfInstances
"Answer a <LookupTable> of the <Aspect>s published by instances of the
receiver."
^(super publishedAspectsOfInstances)
add: (Aspect name: #methodClass) beReadOnly;
add: (Aspect name: #header) beReadOnly;
add: (Aspect integer: #argumentCount) beReadOnly;
add: (Aspect multilineString: #getSource) beReadOnly;
add: (Aspect name: #byteCodes) beReadOnly;
add: (Aspect multilineString: #disassembly) beReadOnly;
add: (Aspect name: #literals);
yourself
You normally work at the instance side, but almost everything is
"defined" at the class side. So you can know what is and what is not
available.
Of course subclasses can "remove" some descriptors from the
LookupTable (optimized Dictionary). Although in Magritte that is
managed by the MAContainer.
Regards!
--
Esteban!