Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!parcplace!parcplace.com!khaw From: khaw@parcplace.com (Mike Khaw) Newsgroups: comp.lang.smalltalk Subject: Re: PP Smalltalk R4 Query, Bug? Keywords: help Message-ID: Date: 11 Mar 91 19:44:23 GMT References: <4931@goanna.cs.rmit.oz.au> Sender: news@parcplace.com Lines: 30 In <4931@goanna.cs.rmit.oz.au> pnm@goanna.cs.rmit.oz.au (Paul Menon) writes: > The other (more efficient?) way: > | aDictionary | > aDictionary := Dictionary new add: #Three->3. > > The second way definitely reduces verbiage, but produces > an Association, not a Dictionary!!! > I've looked up the appendix on implementation limits and there are some > cases which we are warned of, but not this. Even if it were there, why > present it in the User Guide as an example? > On experimenting, I noticed a way around: > | aDictionary | > (aDictionary := Dictionary new) add:#Three->3. It's an error in the User's Guide. In the first version, the result of the add: message (an Association) is assigned to aDictionary, because assignment has lower precedence than unary and selector messages. In the second version, the assignement happens first, then its result (a new instance of Dictionary, referenced as aDictionary) receives the add: message. Although the result returned by the add: message is still an instance of Association, nothing uses the return value. -- Mike Khaw ParcPlace Systems, Inc., 1550 Plymouth St., Mountain View, CA 94043 Domain=khaw@parcplace.com, UUCP=...!{uunet,sun,decwrl}!parcplace!khaw