Anonymous Function

In a programming language, an unnamed function object (also: "function literal").

Example (in PseudoCode):

"lambda(x,y){ x>y }" is an anonymous function object representing the function that tells whether its first argument is greater than its second argument.

This lets you write (e.g.)

  sort(lambda(x,y){ x>y }, [5,7,3,4,9,5,4])
instead of

  def compfunc(x,y) {

Analogously, "42" is an anonymous number object (or "number literal") representing the number 42, which lets you write (e.g.)

instead of

  def value := 42
(for the last code snippet, imagine that this was written in a programming language that does not let you use numbers directly, but always requires you to give them a name first using "def <name> := <value>")

The actual syntax of anonymous functions depends on the programming language being used: Smells of ConfusedComputerScience. Shouldn't this be simply called an unnamed function? -- MarkJanssen

Sometimes it is. In every technical field, science or craft, some things get multiple names.

"Anonymous: not identified by name; of unknown name": doesn't mean it doesn't have a name - but we don't know or care what that name (if it exists) might be. Presumably there is some implementation-level identifier for it.

In fact, in JavaScript it could have a name. Consider the function defined in the statement "var ClarkKent = function Superman(x,y) { return x > y; };". The rest of the world knows of it as "that Function object stored in ClarkKent" and calls it as such; but it knows itself to be "the function named Superman" and calls itself as such. (Except no-one sees Superman. And Superman doesn't know about ClarkKent. Okay, so all analogies are inherently imperfect. Feel free to find a better pair of characters!)
Kid: Mom, when I grow up can I finally get a name, like dad did when he became an object?

Mom: I'm not sure you want to be big and bloated like him, son. Careful what you ask for.

This is funny, but seems to be missing a point and doesn't appear to be related to the above.
See also LambdaExpression

EditText of this page (last edited May 4, 2014) or FindPage with title or text search