Path: utzoo!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!m.cs.uiuc.edu!cs.uiuc.EDU!johnson From: johnson@cs.uiuc.EDU (Ralph Johnson) Newsgroups: comp.lang.smalltalk Subject: Re: PP Smalltalk R4 Query, Bug? Keywords: help Message-ID: <1991Mar9.172040.9335@m.cs.uiuc.edu> Date: 9 Mar 91 17:20:40 GMT References: <4931@goanna.cs.rmit.oz.au> <1991Mar8.140425.10863@m.cs.uiuc.edu> <3086@laura.UUCP> Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager)) Reply-To: johnson@cs.uiuc.EDU (Ralph Johnson) Organization: University of Illinois Lines: 32 Hubert Baumeister pointed out that my explanation of why the Smalltalk class library inventers made add: return the argument was completely wrong, so I'll make a second attempt. There are two choice, either return the receiver or the argument. The way things work now, one can either send a message to the the reciever using cascaded messages or to the argument using parantheses. The standard example of the first situation is aCollection add: thing1; add: thing2; add: thing3 An example of the second situation is (aCollection add: OrderedCollection new) add: thing1; add: thing2 which puts thing1 and thing2 in the OrderedCollection. If add: returned its argument then the first example could be recoded without cascaded messages, but the second example would require a temporary variable. I am pretty sure that this is the reason for the strange semantics of add:. Note that I am not arguing in its favor, I am just explaining it. I've had to explain it over and over again, and I'm pretty tired of it. In my opinion, a few temporary variables would be better than a feature that almost everyone gets wrong at first. However, it is too late to change it now! Ralph Johnson -- University of Illinois at Urbana-Champaign