Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's extremely elegant and readable, when done idiomatically.

  list := OrderedCollection new
            add: 1;
            add: 2;
            add: 3;
            yourself
There's actually a literal syntax for Arrays, but the above example applies to all code and is used heavily in constructors and anything using a builder pattern.


> There's actually a literal syntax for Arrays

Much in the same way as Java, smalltalk-80's arrays are not the most useful thing (they're significantly worse than Java's if I remember correctly, as you can only put other literals in them). So most collections in "user" code are not going to be arrays.

I believe gnu smalltalk extends arrays to be more useful (and adds other collection literals).


> as you can only put other literals in them

What? That's not even close to true. You are misunderstanding something. Actually, I see I think the issue... most Smalltalks have progressed a bit since Smalltalk 80 and now have a fully functional array literal syntax whereas you're talking about the very restrictive original syntax from decades ago.


> Actually, I see I think the issue... most Smalltalks have progressed a bit since Smalltalk 80 and now have a fully functional array literal syntax whereas you're talking about the very restrictive original syntax from decades ago.

I'm talking about Smalltalk-80, hence specifying it, but I know Dolphin Smalltalk still has that restriction.


Well I brought up the Array literals in the context of modern Smalltalk; it makes little sense to respond to that by criticizing a decades old version of Smalltalk. Dolphin is a virtually dead Smalltalk, died officially a while back and was then resurrected, but it's hardly the model of a modern Smalltalk anymore. Visual Works, Pharo, Squeak, and Gemstone are modern Smalltalk's and all have a fully functional array literal syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: