Hi, Please can someone explain the behaviour described
below? I wish to create a subclass of FloatArray for a
dynamic system simulation. When creating the class with #subclass: the method
is automatically changed to #variableWordSubclass: as follows FloatArray variableWordSubclass: #DynamicVariable That is fine. But when I wish to create an instance dv2 _ DynamicVariable new: 2 I get an error telling me that #new: is not
understood. However #new: is understood by the superclass #FloatArray. Why? And, by the way, the method #variableWordSubclass cannot
be found with Method Finder. Why? Many thanks in advance. Joaquin Dr.
Joaquin Sitte, Associate Professor. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Joaquin Sitte a écrit :
> Please can someone explain the behaviour described below? > I wish to create a subclass of FloatArray for a dynamic system > simulation. When creating the class with #subclass: the method is > automatically changed to #variableWordSubclass: as follows > [...] In my opinion, this is the kind of questions you will more likely find answers in squeak-dev. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Joaquin Sitte
Hi Joaquin,
>I wish
to create a subclass of FloatArray for a dynamic system simulation. When
creating the class with #subclass: the method is automatically changed to
#variableWordSubclass: as follows
I think the the expression
"ArrayedCollection subclass: #DynamicVariable" is the right way you get a
subclass of FloatArray.
>FloatArray variableWordSubclass: #DynamicVariable >That is fine. But when I wish to create an instance >dv2 _
DynamicVariable new: 2
So far I've seen the hierarchy of
FloatArray the method "new:" isn't on the class side anywhere. This is
the reason because you get an error.
Hope this helps.
Cheers,
Frank
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
hi-
> So far I've seen the hierarchy of FloatArray the method "new:" isn't on the class side anywhere. This is the reason because you get an error. i'm a real rookie here, but what does it mean - "new:" isn't on the class side anywhere? where is "new:" then? john cummings _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Frank Urbach
>>dv2 _ DynamicVariable new: 2
> > So far I've seen the hierarchy of FloatArray the method "new:" isn't on > the class side anywhere. This is the reason because you get an error. #new: is implemented in Behavior which is the superclass of Class. FloatArray new: 5 is correct for example _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by cummij
> where is "new:" then?
The method whose selector is #new: is implemented on the instance side of Behavior and on the class side of some other classes (String, Set, Array...). _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by cummij
Hi John,
>> So far I've seen the hierarchy of FloatArray the method "new:" >> isn't on the class side anywhere. This is the reason because you >> get an error. cre> i'm a real rookie here, but what does it mean - "new:" isn't on the cre> class side anywhere? where is "new:" then? if you can't find new: up the hierarchy the things to look for are metaclsses and the class Behaviour. In the free books Stephane Ducasse collected Hopkins Horan provides a chapter on this topic. It's a bit brain twisting and when reading I decided I could get by without really knowing about this detail :-)) Maybe someone else can shed more light on this, otherwise retry on squeak-dev. Cheers, Herbert mailto:[hidden email] _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Joaquin Sitte
Joaquin,
> I wish to create a subclass of FloatArray for a dynamic system simulation. When creating the class with #subclass: the > method is automatically changed to #variableWordSubclass: as follows > > FloatArray variableWordSubclass: #DynamicVariable > > That is fine. But when I wish to create an instance > > dv2 _ DynamicVariable new: 2 > > I get an error telling me that #new: is not understood. However #new: is understood by the superclass #FloatArray. Why? I tried this and didn't get any error. I managed to create an instance of DynamicVariable with two slots. > And, by the way, the method #variableWordSubclass cannot be found with Method Finder. Why? I'm not sure how you did this, but if you select from the "v" to "s" above and press Ctrl-w (or Alt-Shift-w), you'll see the selectors that contains the selected string as a part. -- Yoshiki _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Joaquin Sitte
To understand a little bit more:
When you execute (FloatArray new: 2), you send message #new: to class FloatArray with argument 2.
message #new: is looked up in the receiver class methodDictionary, that is (FloatArray class) here.
Note that FloatArray class is a an instance of Metaclass, which is a kind of Behavior.
FloatArray class class.
FloatArray class class superclass superclass.
If #new: is not implemented in (FloatArray class), it must be in one of the superclass.
FloatArray class allSuperclasses.
You got an OrderedCollection(ArrayedCollection class SequenceableCollection class Collection class Object class ProtoObject class Class ClassDescription Behavior Object ProtoObject)
What is causing you trouble is that the hierarchy browser is hiding this hierarchy...
>From the Browser,
FloatArray browseHierarchy
you can only see:
FloatArray allSuperclasses.
And this one only show you a HierarchyBrowser on Metaclass:
FloatArray class browseHierarchy.
I remember from a browser showing the whole Metaclass hierarchy once (was it parcplace st-80 v2.3 ?). Maybe it would help newbies understand better this subtle part of Smalltalk.
Hope it helps.
Nicolas
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Joaquin Sitte
Sorry to repost, my webmail interface was using html instead of plain text...
To understand a little bit more: When you execute (FloatArray new: 2), you send message #new: to class FloatArray with argument 2. Message #new: is looked up in the receiver class methodDictionary, that is (FloatArray class) here. Note that (FloatArray class) is a an instance of Metaclass: FloatArray class class. which is a kind of Behavior: FloatArray class class superclass superclass. If #new: is not implemented in (FloatArray class), it must be in one of its successive superclasses. FloatArray class allSuperclasses. You get an OrderedCollection(ArrayedCollection class SequenceableCollection class Collection class Object class ProtoObject class Class ClassDescrip tion Behavior Object ProtoObject) What is causing you trouble is that the hierarchy browser is hiding this hierarchy... >From the Browser, FloatArray browseHierarchy. you can only see: FloatArray allSuperclasses. And this one only show you a HierarchyBrowser on Metaclass: FloatArray class browseHierarchy. I remember from a browser showing the whole Metaclass hierarchy once... (was it parcplace st-80 v2.3 ?). Maybe it would help newbies understand better this subtle part of Smalltalk. Hope it helps. Nicolas ________________________________________________________________________ iFRANCE, exprimez-vous ! http://web.ifrance.com _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Yoshiki Ohshima
Many thanks to all who replied with advice.
Here is an update on the matter for those interested. DynamicVariable is a subclass (variableWordSubclass) of FloatArray. FloatArray new: 2 works! Therefore because DynamicVariable is a subclass of FloatArray DynamicVariable new: 2 should work, but id didnt for me. A partial solution to my problem was provided by Yoshiki Ohshima who reported getting no error when executing dv2 _ DynamicVariable new: 2 with DynamicVariable variable defined as a subclass of FloatArray. That means I am doing something wrong. I tried to define another class DynamicVariable2 in the same way, and do not get an error message when doing dv2 _ DynamicVariable new: 2 Great! But still my identically defined DynamicVariable still does not understand #new: (tried both Squeak 3.7 and 3.8 with identical results) Obviously something is wrong somewhere in my system. Dont know yet what. Thanks again Joaquin Dr. Joaquin Sitte, Associate Professor. School of Software Engineering and Data Communication Faculty of Information Technology Queensland University of Technology GPO Box 2434, Brisbane, Q 4001 Australia Phone +61 7 3864 2755 Fax +61 7 3864 1801 e-mail: [hidden email] homepage http://www.fit.qut.edu.au/~sitte > -----Original Message----- > From: [hidden email] [mailto:beginners- > [hidden email]] On Behalf Of Yoshiki Ohshima > Sent: Tuesday, 27 June 2006 03:34 > To: A friendly place to get answers to even the most basic questionsabout > Squeak. > Subject: Re: [Newbies] variableWordSubclass: > > Joaquin, > > > I wish to create a subclass of FloatArray for a dynamic system > simulation. When creating the class with #subclass: the > > method is automatically changed to #variableWordSubclass: as follows > > > > FloatArray variableWordSubclass: #DynamicVariable > > > > That is fine. But when I wish to create an instance > > > > dv2 _ DynamicVariable new: 2 > > > > I get an error telling me that #new: is not understood. However #new: is > understood by the superclass #FloatArray. Why? > > I tried this and didn't get any error. I managed to create an > instance of DynamicVariable with two slots. > > > And, by the way, the method #variableWordSubclass cannot be found with > Method Finder. Why? > > I'm not sure how you did this, but if you select from the "v" to "s" > above and press Ctrl-w (or Alt-Shift-w), you'll see the selectors that > contains the selected string as a part. > > -- Yoshiki > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
G'day Joaquin,
on Sun, 02 Jul 2006 14:39:07 +0200, wrote: ... > But still my identically defined DynamicVariable still does not > understand > #new: (tried both Squeak 3.7 and 3.8 with identical results) > > Obviously something is wrong somewhere in my system. Don’t know yet what. ... We can find out for you: just after you encounter the error, Squeak writes a file named SqueakDebug.log into its current directory. Feel free to post the contents of the file here and I'll see that I find you the bug. /Klaus _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |