<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
(	O
function	B-General_Concept
literal	I-General_Concept
,	O
lambda	B-Language
abstraction	I-Language
,	O
lambda	B-General_Concept
function	I-General_Concept
,	O
lambda	B-General_Concept
expression	I-General_Concept
or	O
block	O
)	O
is	O
a	O
function	O
definition	O
that	O
is	O
not	O
bound	O
to	O
an	O
identifier	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
are	O
often	O
arguments	O
being	O
passed	O
to	O
higher-order	B-Language
functions	I-Language
or	O
used	O
for	O
constructing	O
the	O
result	O
of	O
a	O
higher-order	B-Language
function	I-Language
that	O
needs	O
to	O
return	O
a	O
function	O
.	O
</s>
<s>
If	O
the	O
function	O
is	O
only	O
used	O
once	O
,	O
or	O
a	O
limited	O
number	O
of	O
times	O
,	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
may	O
be	O
syntactically	O
lighter	O
than	O
using	O
a	O
named	O
function	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
are	O
ubiquitous	O
in	O
functional	B-Language
programming	I-Language
languages	I-Language
and	O
other	O
languages	O
with	O
first-class	B-Application
functions	I-Application
,	O
where	O
they	O
fulfil	O
the	O
same	O
role	O
for	O
the	O
function	O
type	O
as	O
literals	O
do	O
for	O
other	O
data	O
types	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
originate	O
in	O
the	O
work	O
of	O
Alonzo	O
Church	O
in	O
his	O
invention	O
of	O
the	O
lambda	B-Language
calculus	I-Language
,	O
in	O
which	O
all	O
functions	O
are	O
anonymous	O
,	O
in	O
1936	O
,	O
before	O
electronic	O
computers	O
.	O
</s>
<s>
In	O
several	O
programming	O
languages	O
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
introduced	O
using	O
the	O
keyword	O
lambda	B-General_Concept
,	O
and	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
often	O
referred	O
to	O
as	O
lambdas	B-General_Concept
or	O
lambda	B-Language
abstractions	I-Language
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
have	O
been	O
a	O
feature	O
of	O
programming	O
languages	O
since	O
Lisp	B-Language
in	O
1958	O
,	O
and	O
a	O
growing	O
number	O
of	O
modern	O
programming	O
languages	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
The	O
names	O
"	O
lambda	B-Language
abstraction	I-Language
"	O
,	O
"	O
lambda	B-General_Concept
function	I-General_Concept
"	O
,	O
and	O
"	O
lambda	B-General_Concept
expression	I-General_Concept
"	O
refer	O
to	O
the	O
notation	O
of	O
function	O
abstraction	O
in	O
lambda	B-Language
calculus	I-Language
,	O
where	O
the	O
usual	O
function	O
would	O
be	O
written	O
(	O
is	O
an	O
expression	O
that	O
uses	O
)	O
.	O
</s>
<s>
Compare	O
to	O
the	O
Python	B-Language
syntax	O
of	O
.	O
</s>
<s>
The	O
name	O
"	O
arrow	B-General_Concept
function	I-General_Concept
"	O
refers	O
to	O
the	O
mathematical	O
"	O
maps	O
to	O
"	O
symbol	O
,	O
.	O
</s>
<s>
Compare	O
to	O
the	O
JavaScript	B-Language
syntax	O
of	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
can	O
be	O
used	O
for	O
containing	O
functionality	O
that	O
need	O
not	O
be	O
named	O
and	O
possibly	O
for	O
short-term	O
use	O
.	O
</s>
<s>
Some	O
notable	O
examples	O
include	O
closures	B-Language
and	O
currying	B-Application
.	O
</s>
<s>
The	O
use	O
of	O
anonymous	B-General_Concept
functions	I-General_Concept
is	O
a	O
matter	O
of	O
style	O
.	O
</s>
<s>
Using	O
them	O
is	O
never	O
the	O
only	O
way	O
to	O
solve	O
a	O
problem	O
;	O
each	O
anonymous	B-General_Concept
function	I-General_Concept
could	O
instead	O
be	O
defined	O
as	O
a	O
named	O
function	O
and	O
called	O
by	O
name	O
.	O
</s>
<s>
Some	O
programmers	O
use	O
anonymous	B-General_Concept
functions	I-General_Concept
to	O
encapsulate	O
specific	O
,	O
non-reusable	O
code	O
without	O
littering	O
the	O
code	O
with	O
a	O
lot	O
of	O
little	O
one-line	O
normal	O
functions	O
.	O
</s>
<s>
In	O
some	O
programming	O
languages	O
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
commonly	O
implemented	O
for	O
very	O
specific	O
purposes	O
such	O
as	O
binding	O
events	O
to	O
callbacks	O
or	O
instantiating	O
the	O
function	O
for	O
particular	O
values	O
,	O
which	O
may	O
be	O
more	O
efficient	O
,	O
more	O
readable	O
,	O
and	O
less	O
error-prone	O
than	O
calling	O
a	O
more-generic	O
named	O
function	O
.	O
</s>
<s>
The	O
following	O
examples	O
are	O
written	O
in	O
Python	B-Language
3	O
.	O
</s>
<s>
When	O
attempting	O
to	O
sort	O
in	O
a	O
non-standard	O
way	O
,	O
it	O
may	O
be	O
easier	O
to	O
contain	O
the	O
sorting	B-Algorithm
logic	O
as	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
instead	O
of	O
creating	O
a	O
named	O
function	O
.	O
</s>
<s>
Most	O
languages	O
provide	O
a	O
generic	O
sort	O
function	O
that	O
implements	O
a	O
sort	B-Algorithm
algorithm	I-Algorithm
that	O
will	O
sort	O
arbitrary	O
objects	O
.	O
</s>
<s>
Consider	O
this	O
Python	B-Language
code	I-Language
sorting	B-Algorithm
a	O
list	O
of	O
strings	O
by	O
length	O
of	O
the	O
string	O
:	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
in	O
this	O
example	O
is	O
the	O
lambda	B-General_Concept
expression	I-General_Concept
:	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
accepts	O
one	O
argument	O
,	O
x	O
,	O
and	O
returns	O
the	O
length	O
of	O
its	O
argument	O
,	O
which	O
is	O
then	O
used	O
by	O
the	O
sort( )	O
method	O
as	O
the	O
criteria	O
for	O
sorting	B-Algorithm
.	O
</s>
<s>
The	O
expression	O
returned	O
by	O
the	O
lambda	B-General_Concept
function	I-General_Concept
can	O
be	O
assigned	O
to	O
a	O
variable	O
and	O
used	O
in	O
the	O
code	O
at	O
multiple	O
places	O
.	O
</s>
<s>
Another	O
example	O
would	O
be	O
sorting	B-Algorithm
items	O
in	O
a	O
list	O
by	O
the	O
name	O
of	O
their	O
class	O
(	O
in	O
Python	B-Language
,	O
everything	O
has	O
a	O
class	O
)	O
:	O
</s>
<s>
Closures	B-Language
are	O
functions	O
evaluated	O
in	O
an	O
environment	O
containing	O
bound	O
variables	O
.	O
</s>
<s>
The	O
following	O
example	O
binds	O
the	O
variable	O
"	O
threshold	O
"	O
in	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
that	O
compares	O
the	O
input	O
to	O
the	O
threshold	O
.	O
</s>
<s>
Regardless	O
of	O
the	O
reason	O
why	O
a	O
closure	B-Language
is	O
used	O
,	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
is	O
the	O
entity	O
that	O
contains	O
the	O
functionality	O
that	O
does	O
the	O
comparing	O
.	O
</s>
<s>
Currying	B-Application
is	O
the	O
process	O
of	O
changing	O
a	O
function	O
so	O
that	O
rather	O
than	O
taking	O
multiple	O
inputs	O
,	O
it	O
takes	O
a	O
single	O
input	O
and	O
returns	O
a	O
function	O
which	O
accepts	O
the	O
second	O
input	O
,	O
and	O
so	O
forth	O
.	O
</s>
<s>
While	O
the	O
use	O
of	O
anonymous	B-General_Concept
functions	I-General_Concept
is	O
perhaps	O
not	O
common	O
with	O
currying	B-Application
,	O
it	O
still	O
can	O
be	O
used	O
.	O
</s>
<s>
The	O
functions	O
half	O
and	O
third	O
curry	B-Application
the	O
divide	O
function	O
with	O
a	O
fixed	O
divisor	O
.	O
</s>
<s>
The	O
divisor	O
function	O
also	O
forms	O
a	O
closure	B-Language
by	O
binding	O
the	O
variable	O
d	B-Application
.	O
</s>
<s>
A	O
higher-order	B-Language
function	I-Language
is	O
a	O
function	O
that	O
takes	O
a	O
function	O
as	O
an	O
argument	O
.	O
</s>
<s>
This	O
is	O
commonly	O
used	O
to	O
customize	O
the	O
behavior	O
of	O
a	O
generically	O
defined	O
function	O
,	O
often	O
a	O
looping	O
construct	O
or	O
recursion	O
scheme	B-Language
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
are	O
a	O
convenient	O
way	O
to	O
specify	O
such	O
function	O
arguments	O
.	O
</s>
<s>
The	O
following	O
examples	O
are	O
in	O
Python	B-Language
3	O
.	O
</s>
<s>
The	O
following	O
example	O
squares	O
every	O
element	O
in	O
an	O
array	O
with	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
accepts	O
an	O
argument	O
and	O
multiplies	O
it	O
by	O
itself	O
(	O
squares	O
it	O
)	O
.	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
checks	O
if	O
the	O
argument	O
passed	O
to	O
it	O
is	O
even	O
.	O
</s>
<s>
A	O
fold	O
function	O
runs	O
over	O
all	O
elements	O
in	O
a	O
structure	O
(	O
for	O
lists	O
usually	O
left-to-right	O
,	O
a	O
"	O
left	O
fold	O
"	O
,	O
called	O
reduce	O
in	O
Python	B-Language
)	O
,	O
accumulating	O
a	O
value	O
as	O
it	O
goes	O
.	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
here	O
is	O
the	O
multiplication	O
of	O
the	O
two	O
arguments	O
.	O
</s>
<s>
The	O
following	O
is	O
a	O
list	O
of	O
programming	O
languages	O
that	O
support	O
unnamed	O
anonymous	B-General_Concept
functions	I-General_Concept
fully	O
,	O
or	O
partly	O
as	O
some	O
variant	O
,	O
or	O
not	O
at	O
all	O
.	O
</s>
<s>
First	O
,	O
the	O
languages	O
that	O
do	O
not	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
(	O
C	B-Language
,	O
Pascal	B-Application
,	O
Object	B-Language
Pascal	I-Language
)	O
are	O
all	O
statically	O
typed	O
languages	O
.	O
</s>
<s>
However	O
,	O
statically	O
typed	O
languages	O
can	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
For	O
example	O
,	O
the	O
ML	B-Language
languages	I-Language
are	O
statically	O
typed	O
and	O
fundamentally	O
include	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
and	O
Delphi	B-Language
,	O
a	O
dialect	O
of	O
Object	B-Language
Pascal	I-Language
,	O
has	O
been	O
extended	O
to	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
as	O
has	O
C++	B-Language
(	O
by	O
the	O
C++11	B-Language
standard	O
)	O
.	O
</s>
<s>
Second	O
,	O
the	O
languages	O
that	O
treat	O
functions	O
as	O
first-class	B-Application
functions	I-Application
(	O
Dylan	B-Language
,	O
Haskell	B-Language
,	O
JavaScript	B-Language
,	O
Lisp	B-Language
,	O
ML	B-Language
,	O
Perl	B-Language
,	O
Python	B-Language
,	O
Ruby	B-Language
,	O
Scheme	B-Language
)	O
generally	O
have	O
anonymous	B-General_Concept
function	I-General_Concept
support	O
so	O
that	O
functions	O
can	O
be	O
defined	O
and	O
passed	O
around	O
as	O
easily	O
as	O
other	O
data	O
types	O
.	O
</s>
<s>
+	O
List	O
of	O
languages	O
Language	O
Support	O
Notes	O
ActionScript	B-Operating_System
Ada	B-Language
Expression	O
functions	O
are	O
a	O
part	O
of	O
Ada2012	O
ALGOL	B-Language
68	I-Language
APL	B-Language
Dyalog	O
,	O
ngn	O
and	O
dzaima	O
APL	B-Language
fully	O
support	O
both	O
dfns	O
and	O
tacit	O
functions	O
.	O
</s>
<s>
GNU	O
APL	B-Language
has	O
rather	O
limited	O
support	O
for	O
dfns	O
.	O
</s>
<s>
Assembly	B-Language
languages	I-Language
Bash	B-Operating_System
A	O
library	O
has	O
been	O
made	O
to	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
in	O
Bash	B-Operating_System
.	O
</s>
<s>
C	B-Language
Support	O
is	O
provided	O
in	O
Clang	B-Application
and	O
along	O
with	O
the	O
LLVM	B-Application
compiler-rt	O
lib	O
.	O
</s>
<s>
GCC	B-Application
support	O
is	O
given	O
for	O
a	O
macro	O
implementation	O
which	O
enables	O
the	O
possibility	O
of	O
use	O
.	O
</s>
<s>
C#	B-Application
C++	B-Language
As	O
of	O
the	O
C++11	B-Language
standard	O
CFML	B-Language
As	O
of	O
Railo	B-Language
4	O
,	O
ColdFusion	B-Language
10	O
Clojure	B-Language
COBOL	B-Application
Micro	O
Focus	O
's	O
non-standard	O
Managed	O
COBOL	B-Application
dialect	O
supports	O
lambdas	B-General_Concept
,	O
which	O
are	O
called	O
anonymous	O
delegates/methods	O
.	O
</s>
<s>
Curl	B-Language
D	B-Application
Dart	B-Language
Delphi	B-Language
Dylan	B-Language
Eiffel	B-Language
Elm	B-Language
Elixir	B-Language
Erlang	B-Operating_System
F#	B-Operating_System
Excel	B-Application
Excel	B-Application
worksheet	O
function	O
,	O
2021	O
beta	O
release	O
Factor	B-Application
"	O
Quotations	O
"	O
support	O
this	O
Fortran	B-Application
Frink	B-Language
Go	B-Application
Gosu	B-Application
Groovy	B-Application
Haskell	B-Language
Haxe	B-Language
Java	B-Language
Supported	O
in	O
Java	B-Language
8	O
.	O
</s>
<s>
See	O
the	O
Java	B-Language
limitations	O
section	O
below	O
for	O
details	O
.	O
</s>
<s>
JavaScript	B-Language
Julia	B-Application
Kotlin	B-Language
Lisp	B-Language
Logtalk	B-Language
Lua	B-Language
MUMPS	B-Language
Maple	B-Language
MATLAB	B-Language
Maxima	B-Language
Nim	B-Application
OCaml	B-Language
Octave	B-Language
Object	B-Language
Pascal	I-Language
Delphi	B-Language
,	O
a	O
dialect	O
of	O
Object	B-Language
Pascal	I-Language
,	O
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
(	O
formally	O
,	O
anonymous	B-General_Concept
methods	I-General_Concept
)	O
natively	O
since	O
Delphi	B-Language
2009	I-Language
.	O
</s>
<s>
The	O
Oxygene	B-Language
Object	B-Language
Pascal	I-Language
dialect	O
also	O
supports	O
them	O
.	O
</s>
<s>
Objective-C	B-Language
(	O
Mac	O
OS	O
X	O
10.6	O
+	O
)	O
Called	O
blocks	B-Language
;	O
in	O
addition	O
to	O
Objective-C	B-Language
,	O
blocks	B-Language
can	O
also	O
be	O
used	O
on	O
C	B-Language
and	O
C++	B-Language
when	O
programming	O
on	O
Apple	O
's	O
platform.OpenSCAD	O
Function	B-General_Concept
Literal	I-General_Concept
support	O
was	O
introduced	O
with	O
version	O
2021.01	O
.	O
</s>
<s>
Pascal	B-Application
Perl	B-Language
PHP	B-Application
As	O
of	O
PHP	B-Application
5.3.0	O
,	O
true	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
supported	O
.	O
</s>
<s>
Formerly	O
,	O
only	O
partial	O
anonymous	B-General_Concept
functions	I-General_Concept
were	O
supported	O
,	O
which	O
worked	O
much	O
like	O
C#'s	O
implementation	O
.	O
</s>
<s>
PL/I	B-Language
Python	B-Language
Python	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
through	O
the	O
lambda	B-General_Concept
syntax	O
,	O
which	O
supports	O
only	O
expressions	O
,	O
not	O
statements	O
.	O
</s>
<s>
R	B-Language
Racket	B-Operating_System
Raku	B-Application
Rexx	B-Language
RPG	B-Language
Ruby	B-Language
Ruby	B-Language
's	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
inherited	O
from	O
Smalltalk	B-Application
,	O
are	O
called	O
blocks	B-Language
.	O
</s>
<s>
Rust	B-Application
Scala	B-Application
Scheme	B-Language
Smalltalk	B-Application
Smalltalk	B-Application
's	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
blocks	B-Language
.	O
</s>
<s>
Standard	B-Language
ML	I-Language
Swift	B-Application
Swift	B-Application
's	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
Closures	B-Language
.	O
</s>
<s>
Numerous	O
languages	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
or	O
something	O
similar	O
.	O
</s>
<s>
Only	O
some	O
dialects	O
support	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
either	O
as	O
dfns	O
,	O
in	O
the	O
tacit	O
style	O
or	O
a	O
combination	O
of	O
both	O
.	O
</s>
<s>
The	O
anonymous	B-General_Concept
function	I-General_Concept
is	O
not	O
supported	O
by	O
standard	O
C	B-Language
programming	I-Language
language	I-Language
,	O
but	O
supported	O
by	O
some	O
C	B-Language
dialects	O
,	O
such	O
as	O
GCC	B-Application
and	O
Clang	B-Application
.	O
</s>
<s>
The	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
(	O
GCC	B-Application
)	O
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
mixed	O
by	O
nested	O
functions	O
and	O
statement	O
expressions	O
.	O
</s>
<s>
The	O
following	O
example	O
works	O
only	O
with	O
GCC	B-Application
.	O
</s>
<s>
Because	O
of	O
how	O
macros	O
are	O
expanded	O
,	O
the	O
l_body	O
cannot	O
contain	O
any	O
commas	O
outside	O
of	O
parentheses	O
;	O
GCC	B-Application
treats	O
the	O
comma	O
as	O
a	O
delimiter	O
between	O
macro	O
arguments	O
.	O
</s>
<s>
Clang	B-Application
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
called	O
blocks	B-Language
,	O
which	O
have	O
the	O
form	O
:	O
</s>
<s>
The	O
type	O
of	O
the	O
blocks	B-Language
above	O
is	O
return_type	O
( ^	O
)	O
(	O
parameters	O
)	O
.	O
</s>
<s>
Using	O
the	O
aforementioned	O
blocks	B-Language
extension	O
and	O
Grand	B-Operating_System
Central	I-Operating_System
Dispatch	I-Operating_System
(	O
libdispatch	B-Operating_System
)	O
,	O
the	O
code	O
could	O
look	O
simpler	O
:	O
</s>
<s>
C++11	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
called	O
lambda	B-General_Concept
expressions	I-General_Concept
,	O
which	O
have	O
the	O
form	O
:	O
</s>
<s>
This	O
is	O
an	O
example	O
lambda	B-General_Concept
expression	I-General_Concept
:	O
</s>
<s>
C++11	B-Language
also	O
supports	O
closures	B-Language
,	O
here	O
called	O
captures	O
.	O
</s>
<s>
Captures	O
are	O
defined	O
between	O
square	O
brackets	O
[	O
and	O
]	O
in	O
the	O
declaration	O
of	O
lambda	B-General_Concept
expression	I-General_Concept
.	O
</s>
<s>
C++14	B-Language
and	O
newer	O
versions	O
support	O
init-capture	O
,	O
for	O
example	O
:	O
</s>
<s>
The	O
following	O
two	O
examples	O
demonstrate	O
use	O
of	O
a	O
lambda	B-General_Concept
expression	I-General_Concept
:	O
</s>
<s>
The	O
variable	O
total	O
is	O
stored	O
as	O
a	O
part	O
of	O
the	O
lambda	B-General_Concept
function	I-General_Concept
's	O
closure	B-Language
.	O
</s>
<s>
However	O
in	O
C++17	B-Language
,	O
the	O
current	O
object	O
can	O
be	O
captured	O
by	O
value	O
(	O
denoted	O
by	O
*	O
this	O
)	O
,	O
or	O
can	O
be	O
captured	O
by	O
reference	O
(	O
denoted	O
by	O
this	O
)	O
.	O
</s>
<s>
The	O
lambda	B-General_Concept
will	O
have	O
the	O
same	O
access	O
as	O
the	O
member	O
that	O
created	O
it	O
,	O
in	O
terms	O
of	O
protected/private	O
members	O
.	O
</s>
<s>
The	O
specific	O
internal	O
implementation	O
can	O
vary	O
,	O
but	O
the	O
expectation	O
is	O
that	O
a	O
lambda	B-General_Concept
function	I-General_Concept
that	O
captures	O
everything	O
by	O
reference	O
will	O
store	O
the	O
actual	O
stack	O
pointer	O
of	O
the	O
function	O
it	O
is	O
created	O
in	O
,	O
rather	O
than	O
individual	O
references	O
to	O
stack	O
variables	O
.	O
</s>
<s>
However	O
,	O
because	O
most	O
lambda	B-General_Concept
functions	I-General_Concept
are	O
small	O
and	O
local	O
in	O
scope	O
,	O
they	O
are	O
likely	O
candidates	O
for	O
inlining	O
,	O
and	O
thus	O
need	O
no	O
added	O
storage	O
for	O
references	O
.	O
</s>
<s>
If	O
a	O
closure	B-Language
object	O
containing	O
references	O
to	O
local	O
variables	O
is	O
invoked	O
after	O
the	O
innermost	O
block	O
scope	O
of	O
its	O
creation	O
,	O
the	O
behaviour	O
is	O
undefined	B-Language
.	O
</s>
<s>
Lambda	B-General_Concept
functions	I-General_Concept
are	O
function	O
objects	O
of	O
an	O
implementation-dependent	O
type	O
;	O
this	O
type	O
's	O
name	O
is	O
only	O
available	O
to	O
the	O
compiler	O
.	O
</s>
<s>
If	O
the	O
user	O
wishes	O
to	O
take	O
a	O
lambda	B-General_Concept
function	I-General_Concept
as	O
a	O
parameter	O
,	O
the	O
parameter	O
type	O
must	O
be	O
a	O
template	O
type	O
,	O
or	O
they	O
must	O
create	O
a	O
std::function	O
or	O
a	O
similar	O
object	O
to	O
capture	O
the	O
lambda	B-General_Concept
value	O
.	O
</s>
<s>
The	O
use	O
of	O
the	O
auto	O
keyword	O
can	O
help	O
store	O
the	O
lambda	B-General_Concept
function	I-General_Concept
,	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
storing	O
anonymous	B-General_Concept
functions	I-General_Concept
in	O
variables	O
,	O
vectors	O
,	O
and	O
arrays	O
;	O
and	O
passing	O
them	O
as	O
named	O
parameters	O
:	O
</s>
<s>
A	O
lambda	B-General_Concept
expression	I-General_Concept
with	O
an	O
empty	O
capture	O
specification	O
( []	O
)	O
can	O
be	O
implicitly	O
converted	O
into	O
a	O
function	O
pointer	O
with	O
the	O
same	O
type	O
as	O
the	O
lambda	B-General_Concept
was	O
declared	O
with	O
.	O
</s>
<s>
Starting	O
from	O
C++23	B-Language
,	O
a	O
lambda	B-General_Concept
expression	I-General_Concept
can	O
be	O
recursive	O
through	O
explicit	O
this	O
as	O
first	O
parameter	O
:	O
</s>
<s>
The	O
Boost	B-Language
library	I-Language
provides	O
its	O
own	O
syntax	O
for	O
lambda	B-General_Concept
functions	I-General_Concept
as	O
well	O
,	O
using	O
the	O
following	O
syntax	O
:	O
</s>
<s>
In	O
C#	B-Application
,	O
support	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
has	O
deepened	O
through	O
the	O
various	O
versions	O
of	O
the	O
language	O
compiler	O
.	O
</s>
<s>
The	O
language	O
v3.0	O
,	O
released	O
in	O
November	O
2007	O
with	O
.NET	B-Application
Framework	I-Application
v3.5	O
,	O
has	O
full	O
support	O
of	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
C#	B-Application
names	O
them	O
lambda	B-General_Concept
expressions	I-General_Concept
,	O
following	O
the	O
original	O
version	O
of	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
the	O
lambda	B-Language
calculus	I-Language
.	O
</s>
<s>
While	O
the	O
function	O
is	O
anonymous	O
,	O
it	O
cannot	O
be	O
assigned	O
to	O
an	O
implicitly	O
typed	O
variable	O
,	O
because	O
the	O
lambda	B-General_Concept
syntax	O
may	O
be	O
used	O
for	O
denoting	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
or	O
an	O
expression	O
tree	O
,	O
and	O
the	O
choice	O
cannot	O
automatically	O
be	O
decided	O
by	O
the	O
compiler	O
.	O
</s>
<s>
However	O
,	O
a	O
lambda	B-General_Concept
expression	I-General_Concept
can	O
take	O
part	O
in	O
type	O
inference	O
and	O
can	O
be	O
used	O
as	O
a	O
method	O
argument	O
,	O
e.g.	O
</s>
<s>
to	O
use	O
anonymous	B-General_Concept
functions	I-General_Concept
with	O
the	O
Map	O
capability	O
available	O
with	O
System.Collections.Generic.List	O
(	O
in	O
the	O
ConvertAll( )	O
method	O
)	O
:	O
</s>
<s>
Prior	O
versions	O
of	O
C#	B-Application
had	O
more	O
limited	O
support	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
C#	B-Application
v1.0	O
,	O
introduced	O
in	O
February	O
2002	O
with	O
the	O
.NET	B-Application
Framework	I-Application
v1.0	O
,	O
provided	O
partial	O
anonymous	B-General_Concept
function	I-General_Concept
support	O
through	O
the	O
use	O
of	O
delegates	O
.	O
</s>
<s>
This	O
construct	O
is	O
somewhat	O
similar	O
to	O
PHP	B-Application
delegates	O
.	O
</s>
<s>
In	O
C#	B-Application
1.0	O
,	O
delegates	O
are	O
like	O
function	O
pointers	O
that	O
refer	O
to	O
an	O
explicitly	O
named	O
method	O
within	O
a	O
class	O
.	O
</s>
<s>
(	O
But	O
unlike	O
PHP	B-Application
,	O
the	O
name	O
is	O
unneeded	O
at	O
the	O
time	O
the	O
delegate	O
is	O
used	O
.	O
)	O
</s>
<s>
C#	B-Application
v2.0	O
,	O
released	O
in	O
November	O
2005	O
with	O
the	O
.NET	B-Application
Framework	I-Application
v2.0	O
,	O
introduced	O
the	O
concept	O
of	O
anonymous	B-General_Concept
methods	I-General_Concept
as	O
a	O
way	O
to	O
write	O
unnamed	O
inline	O
statement	O
blocks	B-Language
that	O
can	O
be	O
executed	O
in	O
a	O
delegate	O
invocation	O
.	O
</s>
<s>
C#	B-Application
3.0	O
continues	O
to	O
support	O
these	O
constructs	O
,	O
but	O
also	O
supports	O
the	O
lambda	B-General_Concept
expression	I-General_Concept
construct	O
.	O
</s>
<s>
This	O
example	O
will	O
compile	O
in	O
C#	B-Application
3.0	O
,	O
and	O
exhibits	O
the	O
three	O
forms	O
:	O
</s>
<s>
In	O
the	O
case	O
of	O
the	O
C#	B-Application
2.0	O
version	O
,	O
the	O
C#	B-Application
compiler	O
takes	O
the	O
code	O
block	O
of	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
and	O
creates	O
a	O
static	O
private	O
function	O
.	O
</s>
<s>
But	O
the	O
name	O
is	O
not	O
exposed	O
to	O
application	O
code	O
except	O
by	O
using	O
reflection	B-Language
.	O
</s>
<s>
In	O
the	O
case	O
of	O
the	O
C#	B-Application
3.0	O
version	O
,	O
the	O
same	O
mechanism	O
applies	O
.	O
</s>
<s>
Or	O
using	O
an	O
arrow	B-General_Concept
function	I-General_Concept
:	O
</s>
<s>
CFML	B-Language
supports	O
any	O
statements	O
within	O
the	O
function	O
's	O
definition	O
,	O
not	O
simply	O
expressions	O
.	O
</s>
<s>
CFML	B-Language
supports	O
recursive	O
anonymous	B-General_Concept
functions	I-General_Concept
:	O
</s>
<s>
CFML	B-Language
anonymous	B-General_Concept
functions	I-General_Concept
implement	O
closure	B-Language
.	O
</s>
<s>
D	B-Application
uses	O
inline	O
delegates	O
to	O
implement	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Since	O
version	O
2.0	O
,	O
D	B-Application
allocates	O
closures	B-Language
on	O
the	O
heap	O
unless	O
the	O
compiler	O
can	O
prove	O
it	O
is	O
unnecessary	O
;	O
the	O
scope	O
keyword	O
can	O
be	O
used	O
for	O
forcing	O
stack	O
allocation	O
.	O
</s>
<s>
An	O
anonymous	B-General_Concept
function	I-General_Concept
can	O
be	O
assigned	O
to	O
a	O
variable	O
and	O
used	O
like	O
this	O
:	O
</s>
<s>
Dart	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Delphi	B-Language
introduced	O
anonymous	B-General_Concept
functions	I-General_Concept
in	O
version	O
2009	O
.	O
</s>
<s>
Elixir	B-Language
uses	O
the	O
closure	B-Language
fn	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Erlang	B-Operating_System
uses	O
a	O
syntax	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
similar	O
to	O
that	O
of	O
named	O
functions	O
.	O
</s>
<s>
Go	B-Application
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Haskell	B-Language
uses	O
a	O
concise	O
syntax	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
(	O
lambda	B-General_Concept
expressions	I-General_Concept
)	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
are	O
fully	O
integrated	O
with	O
the	O
type	O
inference	O
engine	B-Application
,	O
and	O
support	O
all	O
the	O
syntax	O
and	O
features	O
of	O
"	O
ordinary	O
"	O
functions	O
(	O
except	O
for	O
the	O
use	O
of	O
multiple	O
definitions	O
for	O
pattern-matching	O
,	O
since	O
the	O
argument	O
list	O
is	O
only	O
specified	O
once	O
)	O
.	O
</s>
<s>
In	O
Haxe	B-Language
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
lambda	B-General_Concept
,	O
and	O
use	O
the	O
syntax	O
function(argument-list )	O
expression	O
;	O
.	O
</s>
<s>
Java	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
named	O
Lambda	B-General_Concept
Expressions	I-General_Concept
,	O
starting	O
with	O
JDK	O
8	O
.	O
</s>
<s>
A	O
lambda	B-General_Concept
expression	I-General_Concept
consists	O
of	O
a	O
comma	O
separated	O
list	O
of	O
the	O
formal	O
parameters	O
enclosed	O
in	O
parentheses	O
,	O
an	O
arrow	O
token	O
(	O
->	O
)	O
,	O
and	O
a	O
body	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
are	O
converted	O
to	O
"	O
functional	O
interfaces	O
"	O
(	O
defined	O
as	O
interfaces	O
that	O
contain	O
only	O
one	O
abstract	O
method	O
in	O
addition	O
to	O
one	O
or	O
more	O
default	O
or	O
static	O
methods	O
)	O
,	O
as	O
in	O
the	O
following	O
example	O
:	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
that	O
implement	O
IntegerMath	O
are	O
passed	O
to	O
the	O
apply( )	O
method	O
to	O
be	O
executed	O
.	O
</s>
<s>
Java	B-Language
8	O
introduced	O
another	O
mechanism	O
named	O
method	O
reference	O
(	O
the	O
::	O
operator	O
)	O
to	O
create	O
a	O
lambda	B-General_Concept
on	O
an	O
existing	O
method	O
.	O
</s>
<s>
In	O
the	O
example	O
above	O
,	O
the	O
functional	O
interface	O
IntBinaryOperator	O
declares	O
an	O
abstract	O
method	O
int	O
applyAsInt(int, int )	O
,	O
so	O
the	O
compiler	O
looks	O
for	O
a	O
method	O
int	O
sum(int, int )	O
in	O
the	O
class	O
java.lang.Integer	O
.	O
</s>
<s>
of	O
lambda-compatible	O
interfaces	O
are	O
similar	O
,	O
but	O
not	O
exactly	O
equivalent	O
,	O
to	O
lambda	B-General_Concept
expressions	I-General_Concept
.	O
</s>
<s>
The	O
main	O
difference	O
here	O
is	O
that	O
the	O
lambda	B-General_Concept
expression	I-General_Concept
does	O
not	O
necessarily	O
need	O
to	O
allocate	O
a	O
new	O
instance	O
for	O
the	O
,	O
and	O
can	O
return	O
the	O
same	O
instance	O
every	O
time	O
this	O
code	O
is	O
run	O
.	O
</s>
<s>
Additionally	O
,	O
in	O
the	O
OpenJDK	B-Language
implementation	O
at	O
least	O
,	O
lambdas	B-General_Concept
are	O
compiled	O
to	O
instructions	O
,	O
with	O
the	O
lambda	B-General_Concept
body	O
inserted	O
as	O
a	O
static	O
method	O
into	O
the	O
surrounding	O
class	O
,	O
rather	O
than	O
generating	O
a	O
new	O
class	O
file	O
entirely	O
.	O
</s>
<s>
Java	B-Language
8	O
lambdas	B-General_Concept
have	O
the	O
following	O
limitations	O
:	O
</s>
<s>
Lambdas	B-General_Concept
can	O
throw	O
checked	O
exceptions	O
,	O
but	O
such	O
lambdas	B-General_Concept
will	O
not	O
work	O
with	O
the	O
interfaces	O
used	O
by	O
the	O
Collection	O
API	B-Application
.	O
</s>
<s>
Variables	O
that	O
are	O
in-scope	O
where	O
the	O
lambda	B-General_Concept
is	O
declared	O
may	O
only	O
be	O
accessed	O
inside	O
the	O
lambda	B-General_Concept
if	O
they	O
are	O
effectively	O
final	O
,	O
i.e.	O
</s>
<s>
if	O
the	O
variable	O
is	O
not	O
mutated	O
inside	O
or	O
outside	O
of	O
the	O
lambda	B-General_Concept
scope	O
.	O
</s>
<s>
JavaScript/ECMAScript	O
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
ES6	O
supports	O
"	O
arrow	B-General_Concept
function	I-General_Concept
"	O
syntax	O
,	O
where	O
a	O
=>	O
symbol	O
separates	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
's	O
parameter	O
list	O
from	O
the	O
body	O
:	O
</s>
<s>
This	O
construct	O
is	O
often	O
used	O
in	O
Bookmarklets	B-Language
.	O
</s>
<s>
For	O
example	O
,	O
to	O
change	O
the	O
title	O
of	O
the	O
current	O
document	O
(	O
visible	O
in	O
its	O
window	O
's	O
title	O
bar	O
)	O
to	O
its	O
URL	O
,	O
the	O
following	O
bookmarklet	B-Language
may	O
seem	O
to	O
work	O
.	O
</s>
<s>
Instead	O
,	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
,	O
that	O
does	O
not	O
return	O
a	O
value	O
,	O
can	O
be	O
used	O
:	O
</s>
<s>
The	O
function	O
statement	O
in	O
the	O
first	O
(	O
outer	O
)	O
pair	O
of	O
parentheses	O
declares	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
,	O
which	O
is	O
then	O
executed	O
when	O
used	O
with	O
the	O
last	O
pair	O
of	O
parentheses	O
.	O
</s>
<s>
This	O
is	O
almost	O
equivalent	O
to	O
the	O
following	O
,	O
which	O
populates	O
the	O
environment	O
with	O
f	O
unlike	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
Use	O
void( )	O
to	O
avoid	O
new	O
pages	O
for	O
arbitrary	O
anonymous	B-General_Concept
functions	I-General_Concept
:	O
</s>
<s>
JavaScript	B-Language
has	O
syntactic	O
subtleties	O
for	O
the	O
semantics	O
of	O
defining	O
,	O
invoking	O
and	O
evaluating	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
The	O
following	O
constructs	O
which	O
are	O
called	O
immediately-invoked	B-Language
function	I-Language
expression	I-Language
illustrate	O
this	O
:	O
</s>
<s>
In	O
particular	O
,	O
JavaScript	B-Language
defines	O
a	O
,	O
(	O
comma	O
)	O
operator	O
in	O
the	O
context	O
of	O
a	O
parenthetical	O
expression	O
.	O
</s>
<s>
The	O
first	O
provides	O
no	O
syntactic	O
hint	O
of	O
any	O
resident	O
function	O
but	O
the	O
second	O
MUST	O
evaluate	O
the	O
first	O
parenthetical	O
as	O
a	O
function	O
to	O
be	O
legal	O
JavaScript	B-Language
.	O
</s>
<s>
Note	O
the	O
implications	O
of	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
in	O
the	O
JavaScript	B-Language
fragments	O
that	O
follow	O
:	O
</s>
<s>
in	O
a	O
JavaScript	B-Language
interpreter	B-Application
engine	B-Application
implement	O
easily	O
with	O
these	O
last	O
anonymous	B-General_Concept
function	I-General_Concept
constructs	O
.	O
</s>
<s>
From	O
the	O
implications	O
of	O
the	O
results	O
,	O
it	O
is	O
possible	O
to	O
deduce	O
some	O
of	O
an	O
engine	B-Application
's	O
recursive	O
versus	O
iterative	O
implementation	O
details	O
,	O
especially	O
tail-recursion	B-Language
.	O
</s>
<s>
In	O
Julia	B-Application
anonymous	B-General_Concept
functions	I-General_Concept
are	O
defined	O
using	O
the	O
syntax	O
(	O
arguments	O
)	O
->(expression )	O
,	O
</s>
<s>
Kotlin	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
with	O
the	O
syntax	O
{	O
arguments	O
->	O
expression}	O
,	O
</s>
<s>
Lisp	B-Language
and	O
Scheme	B-Language
support	O
anonymous	B-General_Concept
functions	I-General_Concept
using	O
the	O
"	O
lambda	B-General_Concept
"	O
construct	O
,	O
which	O
is	O
a	O
reference	O
to	O
lambda	B-Language
calculus	I-Language
.	O
</s>
<s>
Clojure	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
with	O
the	O
"	O
fn	O
"	O
special	O
form	O
and	O
#( 	O
)	O
reader	O
syntax	O
.	O
</s>
<s>
Common	B-Language
Lisp	I-Language
has	O
the	O
concept	O
of	O
lambda	B-General_Concept
expressions	I-General_Concept
.	O
</s>
<s>
A	O
lambda	B-General_Concept
expression	I-General_Concept
is	O
written	O
as	O
a	O
list	O
with	O
the	O
symbol	O
"	O
lambda	B-General_Concept
"	O
as	O
its	O
first	O
element	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
can	O
be	O
used	O
inside	O
lambda	B-General_Concept
forms	O
and	O
with	O
the	O
special	O
operator	O
"	O
function	O
"	O
.	O
</s>
<s>
Also	O
,	O
macro	O
lambda	B-General_Concept
exists	O
,	O
which	O
expands	O
into	O
a	O
function	O
form	O
:	O
</s>
<s>
One	O
typical	O
use	O
of	O
anonymous	B-General_Concept
functions	I-General_Concept
in	O
Common	B-Language
Lisp	I-Language
is	O
to	O
pass	O
them	O
to	O
higher-order	B-Language
functions	I-Language
like	O
mapcar	O
,	O
which	O
applies	O
a	O
function	O
to	O
each	O
element	O
of	O
a	O
list	O
and	O
returns	O
a	O
list	O
of	O
the	O
results	O
.	O
</s>
<s>
The	O
lambda	B-General_Concept
form	O
in	O
Common	B-Language
Lisp	I-Language
allows	O
a	O
lambda	B-General_Concept
expression	I-General_Concept
to	O
be	O
written	O
in	O
a	O
function	O
call	O
:	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
in	O
Common	B-Language
Lisp	I-Language
can	O
also	O
later	O
be	O
given	O
global	O
names	O
:	O
</s>
<s>
Scheme	B-Language
's	I-Language
named	O
functions	O
is	O
simply	O
syntactic	O
sugar	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
bound	O
to	O
names	O
:	O
</s>
<s>
Clojure	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
through	O
the	O
"	O
fn	O
"	O
special	O
form	O
:	O
</s>
<s>
There	O
is	O
also	O
a	O
reader	O
syntax	O
to	O
define	O
a	O
lambda	B-General_Concept
:	O
</s>
<s>
Like	O
Scheme	B-Language
,	O
Clojure	B-Language
's	O
"	O
named	O
functions	O
"	O
are	O
simply	O
syntactic	O
sugar	O
for	O
lambdas	B-General_Concept
bound	O
to	O
names	O
:	O
</s>
<s>
In	O
Lua	B-Language
(	O
much	O
as	O
in	O
Scheme	B-Language
)	O
all	O
functions	O
are	O
anonymous	O
.	O
</s>
<s>
A	O
named	O
function	O
in	O
Lua	B-Language
is	O
simply	O
a	O
variable	O
holding	O
a	O
reference	O
to	O
a	O
function	O
object	O
.	O
</s>
<s>
An	O
example	O
of	O
using	O
anonymous	B-General_Concept
functions	I-General_Concept
for	O
reverse-order	O
sorting	B-Algorithm
:	O
</s>
<s>
The	O
Wolfram	B-Language
Language	I-Language
is	O
the	O
programming	O
language	O
of	O
Mathematica	B-Language
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
are	O
important	O
in	O
programming	O
the	O
latter	O
.	O
</s>
<s>
Below	O
are	O
a	O
few	O
anonymous	B-General_Concept
functions	I-General_Concept
that	O
increment	O
a	O
number	O
.	O
</s>
<s>
#1	O
refers	O
to	O
the	O
first	O
argument	O
and	O
&	O
marks	O
the	O
end	O
of	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
Also	O
,	O
Mathematica	B-Language
has	O
an	O
added	O
construct	O
to	O
make	O
recursive	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
in	O
MATLAB	B-Language
or	O
Octave	B-Language
are	O
defined	O
using	O
the	O
syntax	O
@(argument-list )	O
expression	O
.	O
</s>
<s>
In	O
Maxima	B-Language
anonymous	B-General_Concept
functions	I-General_Concept
are	O
defined	O
using	O
the	O
syntax	O
lambda(argument-list,expression )	O
,	O
</s>
<s>
The	O
various	O
dialects	O
of	O
ML	B-Language
support	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
in	O
OCaml	B-Language
are	O
functions	O
without	O
a	O
declared	O
name	O
.	O
</s>
<s>
Here	O
is	O
an	O
example	O
of	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
that	O
multiplies	O
its	O
input	O
by	O
two	O
:	O
</s>
<s>
In	O
the	O
example	O
,	O
fun	O
is	O
a	O
keyword	O
indicating	O
that	O
the	O
function	O
is	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
F#	B-Operating_System
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
as	O
follows	O
:	O
</s>
<s>
Standard	B-Language
ML	I-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
as	O
follows	O
:	O
</s>
<s>
Nim	B-Application
supports	O
multi-line	O
multi-expression	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
may	O
be	O
passed	O
as	O
input	O
parameters	O
of	O
other	O
functions	O
:	O
</s>
<s>
An	O
anonymous	B-General_Concept
function	I-General_Concept
is	O
basically	O
a	O
function	O
without	O
a	O
name	O
.	O
</s>
<s>
Perl	B-Language
5	O
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
as	O
follows	O
:	O
</s>
<s>
Other	O
constructs	O
take	O
bare	O
blocks	B-Language
as	O
arguments	O
,	O
which	O
serve	O
a	O
function	O
similar	O
to	O
lambda	B-General_Concept
functions	I-General_Concept
of	O
one	O
parameter	O
,	O
but	O
do	O
not	O
have	O
the	O
same	O
parameter-passing	O
convention	O
as	O
functions	O
--	O
@_	O
is	O
not	O
set	O
.	O
</s>
<s>
Before	O
4.0.1	O
,	O
PHP	B-Application
had	O
no	O
anonymous	B-General_Concept
function	I-General_Concept
support	O
.	O
</s>
<s>
PHP	B-Application
4.0.1	O
introduced	O
the	O
create_function	O
which	O
was	O
the	O
initial	O
anonymous	B-General_Concept
function	I-General_Concept
support	O
.	O
</s>
<s>
Otherwise	O
,	O
PHP	B-Application
assumes	O
"	O
$x	O
"	O
means	O
the	O
variable	O
$x	O
and	O
will	O
substitute	O
it	O
into	O
the	O
string	O
(	O
despite	O
possibly	O
not	O
existing	O
)	O
instead	O
of	O
leaving	O
"	O
$x	O
"	O
in	O
the	O
string	O
.	O
</s>
<s>
For	O
functions	O
with	O
quotes	O
or	O
functions	O
with	O
many	O
variables	O
,	O
it	O
can	O
get	O
quite	O
tedious	O
to	O
ensure	O
the	O
intended	O
function	O
body	O
is	O
what	O
PHP	B-Application
interprets	O
.	O
</s>
<s>
Each	O
invocation	O
of	O
create_function	O
makes	O
a	O
new	O
function	O
,	O
which	O
exists	O
for	O
the	O
rest	O
of	O
the	O
program	O
,	O
and	O
cannot	O
be	O
garbage	B-General_Concept
collected	I-General_Concept
,	O
using	O
memory	O
in	O
the	O
program	O
irreversibly	O
.	O
</s>
<s>
If	O
this	O
is	O
used	O
to	O
create	O
anonymous	B-General_Concept
functions	I-General_Concept
many	O
times	O
,	O
e.g.	O
,	O
in	O
a	O
loop	O
,	O
it	O
can	O
cause	O
problems	O
such	O
as	O
memory	O
bloat	O
.	O
</s>
<s>
PHP	B-Application
5.3	O
added	O
a	O
new	O
class	O
called	O
Closure	B-Language
and	O
magic	O
method	O
__invoke( )	O
that	O
makes	O
a	O
class	O
instance	O
invocable	O
.	O
</s>
<s>
In	O
this	O
example	O
,	O
$func	O
is	O
an	O
instance	O
of	O
Closure	B-Language
and	O
echo	O
$	O
func($x )	O
is	O
equivalent	O
to	O
echo	O
$func->__invoke($x )	O
.	O
</s>
<s>
PHP	B-Application
5.3	O
mimics	O
anonymous	B-General_Concept
functions	I-General_Concept
but	O
it	O
does	O
not	O
support	O
true	O
anonymous	B-General_Concept
functions	I-General_Concept
because	O
PHP	B-Application
functions	O
are	O
still	O
not	O
first-class	O
objects	O
.	O
</s>
<s>
PHP	B-Application
5.3	O
does	O
support	O
closures	B-Language
but	O
the	O
variables	O
must	O
be	O
explicitly	O
indicated	O
as	O
such	O
:	O
</s>
<s>
Logtalk	B-Language
uses	O
the	O
following	O
syntax	O
for	O
anonymous	O
predicates	O
(	O
lambda	B-General_Concept
expressions	I-General_Concept
)	O
:	O
</s>
<s>
Currying	B-Application
is	O
also	O
supported	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
(	O
in	O
general	O
anonymous	O
predicates	O
)	O
were	O
introduced	O
in	O
Visual	B-Application
Prolog	I-Application
in	O
version	O
7.2	O
.	O
</s>
<s>
mkAdder	O
returns	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
,	O
which	O
has	O
captured	O
the	O
argument	O
X	O
in	O
the	O
closure	B-Language
.	O
</s>
<s>
Python	B-Language
supports	O
simple	O
anonymous	B-General_Concept
functions	I-General_Concept
through	O
the	O
lambda	B-General_Concept
form	O
.	O
</s>
<s>
The	O
executable	O
body	O
of	O
the	O
lambda	B-General_Concept
must	O
be	O
an	O
expression	O
and	O
ca	O
n't	O
be	O
a	O
statement	O
,	O
which	O
is	O
a	O
restriction	O
that	O
limits	O
its	O
utility	O
.	O
</s>
<s>
The	O
value	O
returned	O
by	O
the	O
lambda	B-General_Concept
is	O
the	O
value	O
of	O
the	O
contained	O
expression	O
.	O
</s>
<s>
Lambda	B-General_Concept
forms	O
can	O
be	O
used	O
anywhere	O
ordinary	O
functions	O
can	O
.	O
</s>
<s>
In	O
general	O
,	O
Python	B-Language
convention	O
encourages	O
the	O
use	O
of	O
named	O
functions	O
defined	O
in	O
the	O
same	O
scope	O
as	O
one	O
might	O
typically	O
use	O
an	O
anonymous	B-General_Concept
functions	I-General_Concept
in	O
other	O
languages	O
.	O
</s>
<s>
This	O
is	O
acceptable	O
as	O
locally	O
defined	O
functions	O
implement	O
the	O
full	O
power	O
of	O
closures	B-Language
and	O
are	O
almost	O
as	O
efficient	O
as	O
the	O
use	O
of	O
a	O
lambda	B-General_Concept
in	O
Python	B-Language
.	O
</s>
<s>
In	O
this	O
example	O
,	O
the	O
built-in	O
power	O
function	O
can	O
be	O
said	O
to	O
have	O
been	O
curried	B-Application
:	O
</s>
<s>
In	O
R	B-Language
the	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
defined	O
using	O
the	O
syntax	O
function(argument-list )	O
expression	O
.	O
</s>
<s>
In	O
Raku	B-Application
,	O
all	O
blocks	B-Language
(	O
even	O
those	O
associated	O
with	O
if	O
,	O
while	O
,	O
etc	O
.	O
)	O
</s>
<s>
are	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
Ruby	B-Language
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
by	O
using	O
a	O
syntactical	O
structure	O
called	O
block	O
.	O
</s>
<s>
There	O
are	O
two	O
data	O
types	O
for	O
blocks	B-Language
in	O
Ruby	B-Language
.	O
</s>
<s>
Procs	O
behave	O
similarly	O
to	O
closures	B-Language
,	O
whereas	O
lambdas	B-General_Concept
behave	O
more	O
analogous	O
to	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
In	O
Rust	B-Application
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
closures	B-Language
.	O
</s>
<s>
With	O
closures	B-Language
with	O
a	O
single	O
expression	O
(	O
i.e.	O
</s>
<s>
Closures	B-Language
with	O
no	O
input	O
parameter	O
are	O
written	O
like	O
so	O
:	O
</s>
<s>
Closures	B-Language
may	O
be	O
passed	O
as	O
input	O
parameters	O
of	O
functions	O
that	O
expect	O
a	O
function	O
pointer	O
:	O
</s>
<s>
However	O
,	O
one	O
may	O
need	O
complex	O
rules	O
to	O
describe	O
how	O
values	O
in	O
the	O
body	O
of	O
the	O
closure	B-Language
are	O
captured	O
.	O
</s>
<s>
Fn	O
:	O
the	O
closure	B-Language
captures	O
by	O
reference	O
( &	O
T	O
)	O
.	O
</s>
<s>
FnMut	O
:	O
the	O
closure	B-Language
captures	O
by	O
mutable	O
reference	O
( &	O
mut	O
T	O
)	O
.	O
</s>
<s>
FnOnce	O
:	O
the	O
closure	B-Language
captures	O
by	O
value	O
(	O
T	O
)	O
.	O
</s>
<s>
They	O
help	O
govern	O
how	O
values	O
are	O
moved	O
around	O
between	O
scopes	O
,	O
which	O
is	O
largely	O
important	O
since	O
Rust	B-Application
follows	O
a	O
lifetime	O
construct	O
to	O
ensure	O
values	O
are	O
"	O
borrowed	O
"	O
and	O
moved	O
in	O
a	O
predictable	O
and	O
explicit	O
manner	O
.	O
</s>
<s>
The	O
following	O
demonstrates	O
how	O
one	O
may	O
pass	O
a	O
closure	B-Language
as	O
an	O
input	O
parameter	O
using	O
the	O
Fn	O
trait	O
:	O
</s>
<s>
In	O
Scala	B-Application
,	O
anonymous	B-General_Concept
functions	I-General_Concept
use	O
the	O
following	O
syntax	O
:	O
</s>
<s>
In	O
certain	O
contexts	O
,	O
like	O
when	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
is	O
a	O
parameter	O
being	O
passed	O
to	O
another	O
function	O
,	O
the	O
compiler	O
can	O
infer	O
the	O
types	O
of	O
the	O
parameters	O
of	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
and	O
they	O
can	O
be	O
omitted	O
in	O
the	O
syntax	O
.	O
</s>
<s>
In	O
such	O
contexts	O
,	O
it	O
is	O
also	O
possible	O
to	O
use	O
a	O
shorthand	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
using	O
the	O
underscore	O
character	O
to	O
introduce	O
unnamed	O
parameters	O
.	O
</s>
<s>
In	O
Smalltalk	B-Application
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
blocks	B-Language
and	O
they	O
are	O
invoked	O
(	O
called	O
)	O
by	O
sending	O
them	O
a	O
"	O
value	O
"	O
message	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
GNU	B-Application
Smalltalk	I-Application
,	O
</s>
<s>
Smalltalk	B-Application
blocks	B-Language
are	O
technically	O
closures	B-Language
,	O
allowing	O
them	O
to	O
outlive	O
their	O
defining	O
scope	O
and	O
still	O
refer	O
to	O
the	O
variables	O
declared	O
therein	O
.	O
</s>
<s>
In	O
Swift	B-Application
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
called	O
closures	B-Language
.	O
</s>
<s>
Similarly	O
,	O
Swift	B-Application
also	O
supports	O
implicit	O
return	O
statements	O
for	O
one-statement	O
closures	B-Language
:	O
</s>
<s>
In	O
Tcl	B-Operating_System
,	O
applying	O
the	O
anonymous	O
squaring	O
function	O
to	O
2	O
looks	O
as	O
follows	O
:	O
</s>
<s>
This	O
example	O
involves	O
two	O
candidates	O
for	O
what	O
it	O
means	O
to	O
be	O
a	O
function	O
in	O
Tcl	B-Operating_System
.	O
</s>
<s>
where	O
 { * } 	O
is	O
the	O
expansion	O
prefix	O
(	O
new	O
in	O
Tcl	B-Operating_System
8.5	O
)	O
.	O
</s>
<s>
Command	O
prefixes	O
support	O
currying	B-Application
.	O
</s>
<s>
Command	O
prefixes	O
are	O
very	O
common	O
in	O
Tcl	B-Operating_System
APIs	B-Application
.	O
</s>
<s>
</s>
<s>
This	O
is	O
the	O
part	O
which	O
caches	O
the	O
compiled	O
form	O
of	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
,	O
but	O
it	O
can	O
only	O
be	O
invoked	O
by	O
being	O
passed	O
to	O
the	O
apply	O
command	O
.	O
</s>
<s>
Lambdas	B-General_Concept
do	O
not	O
support	O
currying	B-Application
,	O
unless	O
paired	O
with	O
an	O
apply	O
to	O
form	O
a	O
command	O
prefix	O
.	O
</s>
<s>
Lambdas	B-General_Concept
are	O
rare	O
in	O
Tcl	B-Operating_System
APIs	B-Application
.	O
</s>
<s>
In	O
Vala	B-Language
,	O
anonymous	B-General_Concept
functions	I-General_Concept
are	O
supported	O
as	O
lambda	B-General_Concept
expressions	I-General_Concept
.	O
</s>
<s>
Visual	B-Language
Basic	I-Language
.NET	I-Language
2008	O
introduced	O
anonymous	B-General_Concept
functions	I-General_Concept
through	O
the	O
lambda	B-General_Concept
form	O
.	O
</s>
<s>
Combined	O
with	O
implicit	O
typing	O
,	O
VB	O
provides	O
an	O
economical	O
syntax	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
As	O
with	O
Python	B-Language
,	O
in	O
VB.NET	B-Language
,	O
anonymous	B-General_Concept
functions	I-General_Concept
must	O
be	O
defined	O
on	O
one	O
line	O
;	O
they	O
cannot	O
be	O
compound	O
statements	O
.	O
</s>
<s>
Further	O
,	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
in	O
VB.NET	B-Language
must	O
truly	O
be	O
a	O
VB.NET	B-Language
Function	O
-	O
it	O
must	O
return	O
a	O
value	O
.	O
</s>
<s>
Visual	B-Language
Basic.NET	I-Language
2010	O
added	O
support	O
for	O
multiline	O
lambda	B-General_Concept
expressions	I-General_Concept
and	O
anonymous	B-General_Concept
functions	I-General_Concept
without	O
a	O
return	O
value	O
.	O
</s>
