first-,second- and third-class value
In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.[1] Some programming language theorists require support for anonymous functions as well.[2] In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type.[3] The term was coined byChristopher Strachey in the context of “functions as first-class citizens” in the mid-1960s.[4]
First-class functions are a necessity for the functional programming style, in which the use of higher-order functions is a standard practice. A simple example of a higher-ordered function is the map function, which takes, as its arguments, a function and a list, and returns the list formed by applying the function to each member of the list. For a language to support map, it must support passing a function as an argument.
There are certain implementation difficulties in passing functions as arguments and returning them as results, especially in the presence of non-local variablesintroduced in nested and anonymous functions. Historically, these were termed the funarg problems, the name coming from "function argument".[5] In early imperative languages these problems were avoided by either not supporting functions as result types (e.g. ALGOL 60, Pascal) or omitting nested functions and thus non-local variables (e.g. C). The early functional language Lisp took the approach of dynamic scoping, where non-local variables refer to the closest definition of that variable at the point where the function is executed, instead of where it was defined. Proper support for lexically scoped first-class functions was introduced in Scheme and requires handling references to functions as closures instead of bare function pointers,[4] which in turn makes garbage collection a necessity.
First-class value can be
- passed as an argument
 - returned from a subroutine
 - assigned into a variable.
 
Second-class value just can be passed as an argument.
Third-class value even can't be passed as an argument.
更多:
http://en.wikipedia.org/wiki/First-class_function
http://stackoverflow.com/questions/2578872/about-first-second-and-third-class-value
随机推荐
- 解决Windows 7下IE11无法卸载、无法重新安装,提示安装了更新的IE版本
			
2013年12月14日 iefans 有用户反馈在Windows 7系统上安装IE11时发现安装程序似乎出了问题,等待了很长时间都没有响应之后就断开了电脑的电源.之后IE11浏览器虽然能使用,却无法安 ...
 - 使用VS创建WebPart部件,并部署到SP(待修改)
			
http://www.cnblogs.com/mingmingruyuedlut/archive/2012/12/02/2789488.html
 - HDU 1045(质因数分解)
			
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description Tomor ...
 - URAL 1203 Scientific Conference dp?贪心
			
题目:click here 分明就是贪心怎么会在dp的专题 #include <bits/stdc++.h> using namespace std; typedef unsigned l ...
 - JavaBean的一个小例子
			
一.创建一个javaBean类: UseBean package com.oncall24h.ruchi; import java.io.Serializable; public class UseB ...
 - C语言之新同学年龄
			
新同学年龄 班里来了一名新同学,很喜欢学数学,同学们问他年龄的时候,他说我的年龄平方是个三位数,立方是个四位数,四次方是个六位数.三次方和四次方正好用遍0.1.2.3.4.5.6.7.8.9这10个数 ...
 - Sicily-1009 梅森素数
			
一.梅森素数 素数有无穷多个,却只有极少量的素数能表示成2p-1(p为素数)的形式.在不大于257的素数中,当p=2.3.5.7.13.17.19.31.67.127.257时,2p-1是素数,其它都 ...
 - Average(模拟)
			
Average Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
 - 记录一次SQL查询语句
			
以前发现比较经典的句子,都是记录在电脑上,我今天想搬到博客上,在我看来,写博客真的是一件非常头疼的事,它是内心的一道坎,我必须得跨过它. CREATE TABLE t_jeff ( id int NO ...
 - 自定义UIViewController与xib文件关系深入分析
			
6月14日 上海 OSC 源创会开始报名啦,有很多机械键盘送哦!!! 用xcode模板向工程加入UIViewController sub class的时候,如果选中了with xib for inte ...