[BUG]Morph>>updateableActionMap

rwithers12 at attbi.com rwithers12 at attbi.com
Tue Mar 19 02:56:11 UTC 2002


That looks like a fix to me. :)

I was surprised to read that this doesn't act like a Dictionary.  Then
again, I really don't ever rely on the return of #at:put: for the value.
 Ditto with #add:.  It's just too arbitrary a rule.

Rob

Scott Wallace <scott.wallace at squeakland.org> wrote:
> A terser way here is to use #valueOfProperty:ifAbsentPut:.  The 
> #updateableActionMap method then reduces to:
> 
> updateableActionMap
>    ^ self valueOfProperty: #actionMap ifAbsentPut: [self createActionMap]
> 
>    -- Scott
> 
> 
> PS:  Morphs are not Dictionaries, so the fact that Morph protocols do 
> not conform to Dictionary conventions is not IMO a flaw.  Outside of 
> the Collection hierarchy, setters generally return self -- they do 
> *not* return the value being set.   Notice, by way of analogy, that 
> Collection.add: returns the addee, but Morph.addMorph: returns self.
> 
> 
> At 11:15 AM -0800 3/18/02, Jim Benson wrote:
> 
> >  > I am not sure I see the two issues with your posted code, other than an
> >>  assumption that #setProperty:toValue: returns the value, like all good
> >>  Dictionary insertion protocols.
> >
> >#setProperty:toValue: is a bad dog ;-)
> 
> <snips>
> 
> >  > > I would think it would be along the lines of:
> >>  >
> >  > > updateableActionMap
> >>  > | actionMap |
> >>  >     ^ self valueOfProperty: #actionMap
> >>  >         ifAbsent: [ actionMap := self setProperty: #actionMap
> >  > > toValue: self
> >  > > createActionMap.
> >  > >             actionMap].



More information about the Squeak-dev mailing list