[ANSI-Smalltalk] re: array creation syntax

Michael Klein mklein at alumni.caltech.edu
Mon Apr 21 16:45:01 BST 2008


On Apr 21, 2008, at 12:41 AM, Panu Logic wrote:

> Michael Klein wrote:
>> I think the brace array syntax encourages the use of arrays
>> as ad-hoc object without classes.
> I don't think "ad-hoc objects" are bad by definition.
>
> If instead you create a new class, but use that
> class only once,  that  bloats  the code  unnecessarily
> - and makes it harder to browse  the class-hierarchy.
> It leads to too many classes.

And if you don't create the class and use it once,
you won't see the opportunity to use it the second time, etc.
Besides, almost everywhere I've seen it used, has
been more than once.

> The situation is the same with blocks.  You could
> say that a block is an ad-hoc method.  That doesn't
> mean that blocks are bad. You could replace
> (the content of) any  block with a method-call to self.
> But that would lead to too many methods.
>
> Giving a name to something is justified when the
> thing named is used in more than one or two places.
> If a thing is used only once, giving it a name and
> definition would be overhead.

Again, rather than show example code, since most
of the people on this list are not new to Smalltalk,
We should start pointing to good & bad usages,
in the wild, of actual code.  I've only seen them in Squeak.
This is, of course, what Andres originally asked for.

> And note that Arrays are Objects too. If they are
> "ad-hoc" it means they are created "for a specific
> purpose". Nothing wrong with that. Same goes
> for Dictionaries. They are ad-hoc too.

Yes, but no one has proposed adding syntax for Dictionaries.
Or Sets.  For that matter, the curly braces remind me a lot more
of sets than arrays, but the square bracket's already taken.

The Array syntax costs too much and adds too little.
I suppose I would be remiss if I didn't introduce syntax macros
into the thread.



More information about the ANSI-Smalltalk mailing list