2009/7/17 John Escobedo <[email protected]>: > Hi everyone, > > I'm new to both Smalltalk and especially to Pharo (and this mailing list). > I have a very basic question and would like to be directed to more > info or a different mailing list if appropriate. > > For most tutorials (I'm using squeak tutorials), one does a lot of > work in a workspace. > > If I make a new global variable such as: > > MySquare := Morph new > > ...once I define "MySquare" as a global variable I know I can send it > many messages like: > > > MySquare openInWorld > MySquare color: Color yellow > > When I'm done and I close the workspace, save the image and save the > image. When I open it again it will know what "MySquare" is known in > any workspace. > > How do I remove "MySquare" and/or the associated object? > How could I see or find other such global variables? > Smalltalk inspect - gives you all the globals :) And to remove, as in any dictionary , use: Smalltalk removeKey: #MyGlobal but beware, if your global is a class, you'd better remove it using tools (or specialized method for removing classes).
My personal advice (or take it as a opinion) : - NEVER USE any globals except from class names. - try to avoid referencing "uncommon" globals directly in methods. Better create an accessor method to it, and put a reference in there, and then use this accessor in the rest of your methods. In this way, if you would want to get rid of it, rename it, or refactor it - you will know that all you need to do is to change a single method, rather than 100000 of methods, which referencing this global. > - John > > _______________________________________________ > Pharo-project mailing list > [email protected] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Best regards, Igor Stasenko AKA sig. _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
