Path: utzoo!news-server.csri.toronto.edu!rutgers!mcnc!nowhere!rick From: rick@cua.cary.ibm.com (Rick DeNatale) Newsgroups: comp.lang.smalltalk Subject: Re: PP Smalltalk R4 Query, Bug? Message-ID: <1991Mar11.170449.1386@cua.cary.ibm.com> Date: 11 Mar 91 17:04:49 GMT References: <4931@goanna.cs.rmit.oz.au> <1991Mar8.140425.10863@m.cs.uiuc.edu> Sender: rick@cua.cary.ibm.com Reply-To: rick@cua.cary.ibm.com.UUCP (Rick DeNatale) Organization: cua Lines: 28 In article <1991Mar8.140425.10863@m.cs.uiuc.edu> johnson@cs.uiuc.EDU (Ralph Johnson) writes: >These expressions have always been different, because >the add: messages for collections always returns the >argument, not the receiver. Lot of people think that >this is a design bug, but there *is* a reason for it. > >The reason is because of cascaded messaged. > aCollection add: thing1; > add: thing2; > add: thing3 >will only work if add: returns the receiver. > I don't believe that cascading would work any differently if add: answered the receiver or not. (Actually it answers the argument, not the receiver). Cascading sends the message to the receiver of the previous message regardless of the answer of that message. The real reason (at least in my mind) that add: answers the argument is because it follows the model of at:put:, which returns its argument so you can write code like: value := aDictionary at: someKey ifAbsent: [ aDictionary at: someKey put: someValue] Rick DeNatale