On 24 September 2012 22:57, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
No just make instVarNamed: work on Class/Metaclass
but it works! Wake up: Object instVarNamed: 'superclass' ==> ProtoObject Object class instVarNamed: 'superclass' =>>> ProtoObject class while #instVarNames is an accessor method, since you have: ProtoObject subclass: #Object instanceVariableNames: '' <<< ---- from here classVariableNames: 'DependentsFields' poolDictionaries: '' category: 'Kernel-Objects' so, Object instVarNames ==> #() Point instVarNames #('x' 'y') And if you want to know, what instance variables an Object (as an object) has, you can always do: Object class allInstVarNames #('superclass' 'methodDict' 'format' 'layout' 'instanceVariables' 'organization' 'subclasses' 'name' 'classPool' 'sharedPools' 'environment' 'category' 'traitComposition' 'localSelectors') And then , access the values: Object instVarNamed: 'category' ==> #'Kernel-Objects' And then what Mariano proposing with renaming an accessor to 'myInstVarNames' sounds like an absurd, then we should probably think about renaming all accessors in all classes like that, i.e. instead (1@2) x we should write (1@2) myX or #getX and so on..
On Sep 24, 2012, at 8:24 PM, Guillermo Polito wrote:
What if we do it the other way? Add #variableNames to the instances :)
Nautilus new variableNames = Nautilus instVarNames.
And them
Nautilus new variableNames ==> #('announcer' 'browsedEnvironment' 'browsingHistory' 'plugins' 'selectedCategory' 'selectedClass' 'selectedGroup' 'selectedMethod' 'selectedPackage' 'showCategories' 'showComment' 'showGroups' 'showHierarchy' 'showInstance' 'showPackages' 'ui' 'uiClass')
Nautilus new instVarNamed: 'announcer'
?
Of course, that will happen/work at metaclass level too.
Maybe rename #instVarNames to #myInstancesVariableNames?
Guille
On Mon, Sep 24, 2012 at 8:18 PM, Camillo Bruni <camillobruni@gmail.com> wrote: On 2012-09-24, at 20:15, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
On Sep 24, 2012, at 6:51 PM, Camillo Bruni wrote:
Nautilus class instVarNames -> #('maxSize' 'cachedLastClasses' 'groups')
ok we get the instance variables
Nautilus class instVarNamed: 'groups' -> error
For me that is wrong. I should not get an error, I should get the actual variable. I mean, why #instVarNames workds but #instVarNamed: doesn't? That is inconsistent.
to me mariano is right. if I can ask a class for a receiver a list of stuff I should be able to send to the same receiver the value of the named elements. this distinction is confusing (Normally I know what is metaclass programming)
but with methods it's the very same, you get them no the class side, but you cannot do anything with them on the class.
The problem is just that on a Class the instance side (of the Metaclass) and the class side collapse, so you have a double interface there.
unless you have a strict and weird kind of separation of these two layers like in Java, you will always have a double set of methods there..
-- Best regards, Igor Stasenko.