[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Dictionary>>#addAll: fails
From: |
Stephen Compall |
Subject: |
Re: [Help-smalltalk] Dictionary>>#addAll: fails |
Date: |
Fri, 23 Mar 2007 13:55:29 -0500 |
On Fri, 2007-03-23 at 15:26 +0100, Paolo Bonzini wrote:
> One possibility could be to extend the {...} syntax to something
> like "OrderedCollection {...}", "Dictionary {...}", and have it send
> messages like "#braceWithAll:". Then you would have:
I would rather leave the syntax alone and just add the protocol:
<collection factory> >> withBraced: anArray
Convert anArray to an instance of the receiver.
anArray is structured such that the instance can be conveniently
and fully specified using brace-syntax, possibly by imposing some
additional structure on anArray.
I feel that this protocol specifies what we want from a semi-literal
syntax, without closing off too many possibilities. withStructure: may
be a better name than the perhaps too specific withBraced:, though the
latter has the advantage of putting the writer in the right mindset to
produce the semantics intended by the protocol. I'll prefer
withBraced:.
> Array >> braceWithAll: x
> ^self
>
> Collection >> braceWithAll: x
> ^self withAll: x
>
> Dictionary >> braceWithAll: x
> | dict |
> dict := self new: x size * 2.
> "in the loop we want 'self add: x' maybe?"
> x do: [ :each | dict at: x key put: x value ].
> ^dict
I like these as they are, except for the * 2 in Dictionary's method.
--
;;; 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
signature.asc
Description: This is a digitally signed message part
- [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, parasti, 2007/03/20
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Paolo Bonzini, 2007/03/20
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Stephen Compall, 2007/03/22
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Jānis Rūcis, 2007/03/22
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Stephen Compall, 2007/03/22
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Paolo Bonzini, 2007/03/23
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Jānis Rūcis, 2007/03/23
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Paolo Bonzini, 2007/03/23
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Jānis Rūcis, 2007/03/23
- Re: [Help-smalltalk] CharacterArray class>>#lineDelimiter and Dictionary>>#addAll: both fail, Paolo Bonzini, 2007/03/23
- Re: [Help-smalltalk] Dictionary>>#addAll: fails,
Stephen Compall <=
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Paolo Bonzini, 2007/03/26
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Stephen Compall, 2007/03/29
- Re: [Help-smalltalk] Re: Dictionary>>#addAll: fails, Paolo Bonzini, 2007/03/30
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Stephen Compall, 2007/03/29
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Jānis Rūcis, 2007/03/29
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Stephen Compall, 2007/03/29
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Jānis Rūcis, 2007/03/30
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Stephen Compall, 2007/03/30
- [Help-smalltalk] Re: Dictionary>>#addAll: fails, Jānis Rūcis, 2007/03/31
- Re: [Help-smalltalk] Re: Dictionary>>#addAll: fails, Paolo Bonzini, 2007/03/31