2 ms·
As far as I can tell, your only actual complaint is that Smalltalk 80 insists on you naming block parameters. Yep, that's not ideal, but it's also a single min
by mpweiher 5y ago
As far as I can tell, your only actual complaint is that Smalltalk 80 insists on you naming block parameters. Yep, that's not ideal, but it's also a single minor issue and trivial to fix, even in Smaltalk 80, because blocks are just objects. Certainly Kotlin's alternative here of special-casing closures with one parameter and randomly assigning the parameter name "it" seems no better, and arguably significantly worse.
The "listOF()" function (is it a function? Or special syntax?) certainly looks a lot worse than actual literal syntax, though I'd agree that Smalltalk 80's literal syntax is not ideal.
In Objective-S, you can still use your own block parameters, but any non-named parameters will be assigned numbered $ names.
list ← #( 1,2,3 ).
list collect:{ $1 + 1 }.
Of course, simple maps don't really require the syntactic overhead of a closure, a Higher Order Message is much better suited:
list collect + 1.
Next example
list select: { ($1 mod: 2) = 0 } | collect + 2.
Keyword syntax allows "operator-like" named methods.
ourList select: { ($1 mod: 2) = 0 } | collect + 2 | collect + 3.