Adding and removing methods

Jules Dubois de6l5rp02 at sneakemail.com
Tue Mar 16 19:28:40 UTC 2004


In article <E1B37Yx-0008Ti-00 at logrus.dnsalias.net>, on Tue, 16 Mar 2004
00:56:12 -0400, Lex Spoon wrote:

> Jules Dubois <de6l5rp02 at sneakemail.com> wrote:
>> I'm writing my first Smalltalk code in Squeak and I've got two
>> questions.
> 
> If you aren't sure, keep in mind that you can always so no and then make
> a snapshot before trying again.  That way, if anything goes wrong, you
> can resume from the latest snapshot.

Is a snapshot what I get if I select "save as new version" from the World
menu?  That would beat copying the "three files" back and forth between
temporary directories like I did when I was experimenting with installing
browsers (in this case, Refactory and Whisker),

>>    For example, I tried to create a 'new' method in one of my classes
>>    and received a message, "Warning: new is used in the existing class
>>    system ...".  Is this just a problem with new?
> 
> You get this warning whenever you define a class method for something
> that is already being used in the system.  This is often a mistake, but
> #new is an exception to this exception.  [...]

I don't quite understand this statement.  It's a mistake for me to use an
existing selector for a new purpose or it's a mistake for me to use
(override) #new?

>>    For example, I created an '==' method in a class but I want to get
>>    rid of it.  When I try to do this, I get a message saying there are
>>    thousands of senders of this message.  It looks to me like Squeak
>>    wants to remove the selector from the system and not simply remove
>>    the method from the class.
> 
> No, it is talking about removing just the method.  Just click "remove
> it" if you want that method to go away.

I did and, as you said, it only removed the selected method.

Squeak obviously knows the '==' message was used in many classes' methods.
My new theory is, stated in terms of '==',

    Squeak can't determine that the receivers of '==' would never be
    instances of my class, so it warned me of the existence of these 
    other receivers when I tried to remove it from my class.

Is this closer to reality as defined by Squeak?

> (And incidentally, you probably
> want to implement =, not ==.  = means the normal "generally the same
> thing", while == means "exactly the same object")

Yes, thanks; at the time I was fooling around, I couldn't remember
which was which -- just like when I was learning LISP.





More information about the Squeak-dev mailing list