Fear and loathing of the "perification" of Smalltalk
Paolo Bonzini
bonzini at gnu.org
Thu Sep 13 06:37:54 UTC 2007
(My first post to squeak-dev, I think).
> "Same as using curly braces but importantly NO syntax changes needed!"
> list := [a. b. c] objects.
I don't buy this. You simplified the syntax, and you have added
complexity to the compiler. Because no, you cannot implement this in
pure Smalltalk (unlike ifTrue:ifFalse: or ifNil:ifNotNil:). Making up
Smalltalk-like syntax that does not have anything to do with Smalltalk,
is one of the most common mistakes I've seen, and the most common sign
that your love for a language has been corrupted into religion.
> "More flexible version that lets you collect the evaluated results
> into an arbitary collection of your own choosing."
> [a. b. c] addObjectsTo: aCollection.
If you want, you can modify the compiler so that
aCollection addAll: {a. b. c}
becomes
aCollection add: a; add: b; add: c.
> "Wow, even into a stream."
> [
> 1 to: 1000 do: [:count | count random ]
> ] streamObjectsInto: aStreamOfRandomIntegers
??? Before proposing something, please ensure that it is implementable.
This would add just "1" to the stream if it parallels to
aStreamOfRandomIntegers nextPutAll: {
1 to: 1000 do: [:count | count random ] }
I prefer to add a tiny bit of complexity to the parser, than to add
compiler special cases that get out of control much more easily than new
syntax.
In GNU Smalltalk, there are two common use cases for {...} that are not
easily replaceable:
aStream nextPutAll: ('%1 (%2)' % { self name. self age })
Dictionary from: { 'Sun'->'Sunday'. 'Mon'->'Monday' "etc" }
Paolo
More information about the Squeak-dev
mailing list
|