[ANSI-Smalltalk] re: array creation syntax
Andres Valloud
andres.valloud at gmail.com
Sat Mar 22 21:33:13 GMT 2008
I think that, without #<- being in all the major Smalltalks first, much less
being common practice in the first place, it is not appropriate to discuss
this for inclusion in the Smalltalk Standard at this time.
Andres.
On Sat, Mar 22, 2008 at 2:22 PM, Panu Logic <panulogic at gmail.com> wrote:
> It all boils down to shorter code. You can write
>
> myArray := Array
> with: self this
> with self that
> with: aVariable
> with: #foo.
>
>
> But after you want more than 4 dynamic elements, you will need
> to do something else, such as create an OrderedCollection and
> start adding things to it, and then perhaps convert it to Array.
> You might decide to define a binary alias for #add:, like #<-
> to save a few keystrokes.
>
> The downside for adding extra syntax for this purpose is that
> it makes the standard thicker, and the language harder to learn.
> Harder to learn means easier to make mistakes, and errors.
>
> For me I don't know which one is better, it's a question of
> Obama vs. Hillary.
>
> -Panu Viljamaa
>
>
>
>
>
> Andres Valloud wrote:
>
> I think something that is being left unaddressed is whether using literal
> arrays that allow code expressions (e.g.: the brace syntax in Squeak) is a
> good practice or not. In my experience, I have not felt the need for such
> things, but maybe I have not been exposed to particular circumstances in
> which they become useful. Does anybody have some slam dunk examples that
> can be shared so that we can evaluate this better?
>
> Andres.
>
> On Tue, Mar 18, 2008 at 9:57 AM, Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
> > On Mon, Mar 17, 2008 at 2:11 PM, Craig Latta <craig at netjam.org> wrote:
> >
> > >
> > > > Defining new language elements is hard. The worst that could
> > > happen
> > > > to this project, is to have extremely long threads with no
> > > conclusion
> > > > as on the Squeak list.
> > >
> > > Indeed, although for what it's worth there's no lingering debate
> > > there on this particular issue[1]. ;)
> > >
> > >
> > > -C
> > >
> > > [1]
> > >
> > > Namely, the short form of...
> > >
> > > Array with: #foo with: #bar
> > >
> > > is...
> > >
> > > #(foo bar)
> > >
> > > as in Smalltalk-80, and the short form of...
> > >
> > > Array with: #foo with: true
> > >
> > > is...
> > >
> > > {#foo. true}
> >
> >
> > Well, in Squeak 3.9 I get
> >
> > Welcome to the finale version of 3.9 of 7 of November 2006
> > #(nil true false foo) collect: [:ea| ea class] {UndefinedObject . True .
> > False . ByteSymbol}
> > #(nil true false foo) printString '#(nil true false #foo)'
> >
> > But I suspect the appropriate standard use of curly brackets
> > > across multiple dialects is a whole other morass. :)
> >
> >
> > Having been living with Squeak for a while now I really, really like the
> > curly brace syntax. I also note that it doesn't conflict with e.g.
> > VisualWorks use of #{name} for binding references. So I have a strong
> > personal preference for it, but that's just personal.
> >
> >
> >
> > _______________________________________________
> > ANSI-Smalltalk mailing list
> > ANSI-Smalltalk at lists.openskills.org
> > http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk
> >
> >
> ------------------------------
>
> _______________________________________________
> ANSI-Smalltalk mailing listANSI-Smalltalk at lists.openskills.orghttp://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk
>
>
>
> _______________________________________________
> ANSI-Smalltalk mailing list
> ANSI-Smalltalk at lists.openskills.org
> http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openskills.org/pipermail/ansi-smalltalk/attachments/20080322/908075ec/attachment.html
More information about the ANSI-Smalltalk
mailing list