Search code examples
programming-languagesanonymous-functionlambdafirst-class-functions

What is different between First-class function and Anonymous function?


I saw two concepts

It seems that these two concepts are the same? (lambda)

I'm confused?


Solution

  • A first class function is one which is reified - i.e. it can be manipulated as part of the language, can be passed to other functions, be the value of a variable.

    An anonymous function is just one which does not have a name (or does not have a "function" name, if functions and variables occupy separate namespaces).

    It would be moderately difficult to design a language with anonymous, non-first-class functions, but the two concepts are sufficiently distinct that you at least kinda-sorta could. Equally, you definitely could have a language with first class functions, but no anonymous functions. These languages are rare, because there's little point in such a design.