5 ms·
I've missed this feature in other languages. Now I have a name, the cascades operator. I don't think the syntax is especially elegant/readable, though.
by grogs 15y ago
I've missed this feature in other languages.
Now I have a name, the cascades operator.
I don't think the syntax is especially elegant/readable, though.
- gnaritas 15y agoIt'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.
- masklinn 15y ago> 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).
- gnaritas 15y ago> 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.
- masklinn 15y 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.
- gnaritas 15y agoWell 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.