Anonymous function syntax
Max Klyga
max.klyga at gmail.com
Wed Sep 21 23:47:20 PDT 2011
Actually Scala doesn't need type declarations in labmda literals. Most
of the time argument types are infered. It would be awesome if D
infered argument types for labdas too.
Also Java 8 adopted the same lambda syntax as Scala and C#.
To add a few things to your list:
Nemerle
fun (x, y) { x + y }
(x, y) => x + y
Scala and Nemerle supports placeholder lambda syntax
_ + _
Scheme
(lambda (x y) (+ x y))
Smalltalk
[ :x :y | x + y ]
ML/Ocaml/F#
fun x y -> x + y
Ruby has a whole zoo of syntaxes
{|x, y| x + y }
->(x, y) { x + y }
do |x, y| x + y end
Groovy
{ x, y -> x + y }
So "(args) => body" is the most common syntax now
More information about the Digitalmars-d
mailing list