help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary


From: Stephen Compall
Subject: Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail
Date: Thu, 22 Mar 2007 21:04:32 -0500

On Fri, 2007-03-23 at 02:29 +0200, Jānis Rūcis wrote:
> I remember now that I was a bit surprised to discover that, in
> Dictionaries, #do: is, in fact, redefined to iterate over values, and
> not the Associations (which is what I meant by "elements").  Removing it
> would preserve the indeed useful behaviour you demonstrated in your
> example and also make it behave the way I expected.  And probably break
> something.  :-)

I agree on the surprise, that changing Dictionary>>#do:'s semantics
would be an acceptable way to get the behavior you want, and that it
would break something.  :)

My suggestion for a new protocol was an attempt to carry over the spirit
of the associationsDo:/do: relationship.

Unfortunately, this seems moot, as revealed by checking ANSI:

5.7.2.1 Message:          addAll: dictionary
   Synopsis
       Store the elements of dictionary in the receiver at the corresponding 
keys from dictionary.
   Definition: <abstractDictionary>
       This message is equivalent to repeatedly sending the #at:put: message to 
the receiver with
       each of the keys and elements in dictionary in turn. If a key in 
dictionary is key equivalent to
       a key in the receiver, the associated element in dictionary replaces the 
element in the receiver.
   Parameters
       dictionary         <abstractDictionary>    unspecified

ANSI seems to solve the add:/addAll: mismatch for Dictionary by leaving
add: out of the protocol -- including the inherited <collection>.
Furthermore, <Dictionary factory>>>#withAll: is equivalent to its
current definition in GST, so its arg must also be an
<abstractDictionary> as implied by the above addAll: definition.

I would suggest that addAllAssociations: have the current behavior of
addAll:, but that would likely lead to confusion, as the relationship
between addAll: and addAllAssociations: would be precisely the opposite
of that between do: and associationsDo:.  On the other hand,
associationsDo: is not even part of <abstractDictionary>....

-- 
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech column
     "Portals" on page B1 of The Wall Street Journal

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]