Mainly Tech projects on Python and Electronic Design Automation.

Thursday, December 03, 2009

What is a first-class function?

There is a debate about it on Wikipedia, and I am curious:
  1. Does a language have first-class functions if it can use its functions to solve particular problems in a certain manner, or
  2. Does a language have first-class functions if functions are just as flexible as other types in the language itself?
It probably means 1. above, as the second definition would omit most static languages, as they might be able, for example, to take textual input and change it into an internal representation of an integer, but not do the same for a function with similar effort. Someone who exclusively thinks in terms of static languages may not have realized a difference.


  1. SICP provides a definition of first-class status:

    In general, programming languages impose restrictions on the ways in which computational elements can be manipulated. Elements with the fewest restrictions are said to have first-class status. Some of the ``rights and privileges'' of first-class elements are:

    * They may be named by variables.
    * They may be passed as arguments to procedures.
    * They may be returned as the results of procedures.
    * They may be included in data structures.


  2. Thanks Pollux.
    With that definition, in isolation, then a dynamic language practitioner might include run-time creation of functions whereas a static language user would not.

    Maybe it is item 2. and in a dynamic language you should include run-time function creation, but not for a static language, leading to two sets of likely properties of first-class functions depending.

  3. @Pollux hit it right on the head!

    It's closer to your 2. than 1.!



Subscribe Now: google

Add to Google Reader or Homepage

Go deh too!

Blog Archive