slebetman said:
Javascript properly supports lambdas
I don't want to be unnecessarily pedantic,[1] but "supports
first-class functions" would be preferable. ("Supports lambda" would
be OK, too, referring to the lambda operator. But that would likely be
confusing for some readers, since ECMAScript doesn't have a "lambda"
keyword, unlike LISP and friends.)
Lambda is the name of the abstraction operator. It creates a function.
In many languages it also creates a closure, which is the function
plus its bound variables; many people use "closure" to refer to the
function, which is not technically correct but close enough for many
purposes.
Calling a function or closure a "lambda" is like calling a sum an "add".
What you are saying above is that ECMAScript lets you pass function
references as parameters, and then apply them. That's a consequence of
having first-class functions.
Of course, there are languages where functions are not first-class,
but you can still pass function references and apply them. C, for
example, where functions cannot be created during program execution
(no dynamic functions) but can be called by reference. For example:
-----
int foo(int x, int y) { return x + y; }
int bar(int(*fnref)(int,int), p1, p2) { return fnref(p1, p2); }
int main(void) { return bar(foo, 1, 2); }
-----
(Note that in C a function pointer is implicitly dereferenced by the
function-call operator, so it's not necessary to write "(*fnref)" when
calling it.)
In COBOL, where functions ("programs") are again not first-class, you
can call a function literally using a string literal, or through a
reference, or using a string variable that contains its name:
call "foo" using 1 2
set fnref to entry "foo"
call fnref using 1 2
move "foo" to fname
call fname using 1 2
which makes call-through-reference and call-with-name-lookup almost
indistinguishable to the casual programmer.
[1] This is a lie, of course. I love pedantry as much as the next poster.