4 ms·
Well, at the very least the new syntax is a tremendous improvement upon the previous proposals. (http://cr.openjdk.java.net/~mr/lambda/straw-man/ http://cr.open
by RodgerTheGreat 16y ago
Well, at the very least the new syntax is a tremendous improvement upon the previous proposals. (http://cr.openjdk.java.net/~mr/lambda/straw-man/ http://cr.openjdk.java.net/~mr/lambda/straw-man/)
Compare the old
#(int x)(x + x)
To the new
{x -> x + x}
Much more consistent with the syntax of normal Java. Seems to be borrowing from C#.
- evilduck 16y agoI hadn't followed up on it since the previous proposal but....thank goodness. The pound-sign lambda annoyed me since other lambda capable languages use it to denote comments. It wasn't a dealbreaker, but it certainly was less than preferred.
- cabalamat 16y agoI agree. I know of no other language where a # is used to denote lambdas. I would prefer one of: 1. a keyword such as fn, fun, function, lambda. (Incidently, my language uses fn) 2. {...} are used to denote code blocks in many languages, including Java 3. -> or => are also used for functions in several languages (IIRC C# uses =>)
- Zak 16y ago# is used for lambda shorthand in Clojure. #(+ % %2) is shorthand for (fn [x y] (+ x y)).
- cabalamat 16y agoThat's a nice shorthand. AIUI, Arc uses [... _ ....] as a terse shorthand for closures, but can only deal with functions that take one argument that way -- though it would be simple to expand Arc so it could say [+ _ _2]. Now I've thought about it, I may add something similar as syntax in Unify: (tn + _ _2) (where tn stands for "terse function")