I'm trying to go through the pipsqueak tutorial, but it throws a
doesNotUnderstand error when I try to initialize the exitSides instance variable the first time. The browser shows the exitSides variable (with nil value), so the VM knows its there. This is my class declaration: Object subclass: #BlankCell instanceVariableNames: 'activeSegments exitSides' classVariableNames: '' poolDictionaries: '' category: 'Laser-Game-Model' This is my init function: initializeExitSides self exitSides: Dictionary new. self exitSides at: #north put: #south. self exitSides at: #east put: #west. self exitSides at: #south put: #north. self exitSides at: #west put: #east. And a screen shot of my error stack trace is here: http://www.isi.edu/~amarshal/transfers/squeak_error.png (How do I copy it as text anyway?) Anm _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Andrew n marshall wrote:
> I'm trying to go through the pipsqueak tutorial, but it throws a > doesNotUnderstand error when I try to initialize the exitSides > instance variable the first time. The browser shows the exitSides > variable (with nil value), so the VM knows its there. > > This is my class declaration: > Object subclass: #BlankCell > instanceVariableNames: 'activeSegments exitSides' > classVariableNames: '' > poolDictionaries: '' > category: 'Laser-Game-Model' > > This is my init function: > initializeExitSides > self exitSides: Dictionary new. Karl > self exitSides at: #north put: #south. > self exitSides at: #east put: #west. > self exitSides at: #south put: #north. > self exitSides at: #west put: #east. > > And a screen shot of my error stack trace is here: > http://www.isi.edu/~amarshal/transfers/squeak_error.png > (How do I copy it as text anyway?) > > > Anm > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Karl a écrit :
> Andrew n marshall wrote: >> I'm trying to go through the pipsqueak tutorial, but it throws a >> doesNotUnderstand error when I try to initialize the exitSides >> instance variable the first time. The browser shows the exitSides >> variable (with nil value), so the VM knows its there. >> >> This is my class declaration: >> Object subclass: #BlankCell >> instanceVariableNames: 'activeSegments exitSides' >> classVariableNames: '' >> poolDictionaries: '' >> category: 'Laser-Game-Model' >> >> This is my init function: >> initializeExitSides >> self exitSides: Dictionary new. create it (the accessor) or you directly affect the instance variable. BlankCell>>existSide: aDictionary existSide := aDictionary or you replace in you initialize method "self exitSides: Dictionary" new by: existSide := Dictionary new > >> self exitSides at: #north put: #south. >> self exitSides at: #east put: #west. >> self exitSides at: #south put: #north. >> self exitSides at: #west put: #east. >> >> And a screen shot of my error stack trace is here: >> http://www.isi.edu/~amarshal/transfers/squeak_error.png >> (How do I copy it as text anyway?) >> >> >> Anm >> _______________________________________________ >> Beginners mailing list >> [hidden email] >> http://lists.squeakfoundation.org/mailman/listinfo/beginners >> > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Andrew n marshall-2
On Nov 14, 2007, at 5:35 , Andrew n marshall wrote:
> And a screen shot of my error stack trace is here: > http://www.isi.edu/~amarshal/transfers/squeak_error.png > (How do I copy it as text anyway?) It is automatically saved as SqueakDebug.log. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by cedreek
Cédrick Béler wrote: > The error message says that #existSides: doesn't exist. So either you > create it (the accessor) or you directly affect the instance variable. > > BlankCell>>existSide: aDictionary > existSide := aDictionary > > or you replace in you initialize method "self exitSides: Dictionary" > new by: > existSide := Dictionary new Where are you getting "existSides"? Everything I see in the stack screen shot and in my email says "exitSides"? I'm going to assume that was a mistake, and you're suggesting the same thing Karl mentioned. If I do this, it "doesNotUnderstand" the following line. But I see the var is set, so I remove self from all the following lines. The accessor complains similarly, and I remove self from it also. It works, but I'm confused and concerned now. Why does the tutorial ( http://squeak.preeminent.org/tut2007/html/021.html ) recommend the other form, and why does that form work for activeSegments (my other instance variable, which is also a Dictionary) but not exitSides: initializeActiveSegments self activeSegments: Dictionary new. self activeSegments at: #north put: false. self activeSegments at: #east put: false. self activeSegments at: #south put: false. self activeSegments at: #west put: false. In my mind, I now have two instance variables of Dictionarys that I have to initialize and reference in different ways. I just realized activeSegments has an accessor / mutator pair. So, is this an omission of the tutorial, forgetting to mention the those methods? Am I correct in concluding methods calls are always prefixed by the class instance variable name (in this case "self) while instance variables of self are referenced directly? _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
I just noticed "As before, create accessors" on the tutorial page. Still, that I can reference instance variables directly is enlightening. Does a subclass have the same access privilege, or must I use accessors when reference superclass instance variables? Anm _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 11/14/07, Andrew n marshall <[hidden email]> wrote:
Subclasses can also directly reference instance variables defined in superclasses as well.
-Chris _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |