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
随机推荐
- Oracle更改数据库文件大小、实时增加文件容量
--查询数据库文件路径.表空间.大小等 select * from dba_data_files ; --EAST.DBF数据库文件自动扩展20M,可无限扩展 alter database dataf ...
- [Swust OJ 795]--Penney Game
题目链接:http://acm.swust.edu.cn/problem/795/ Time limit(ms): 1000 Memory limit(kb): 65535 Description ...
- hdu 4372 第一类stirling数的应用/。。。好题
/** 大意: 给定一系列楼房,都在一条水平线上,高度从1到n,从左侧看能看到f个, 从右侧看,能看到b个,问有多少种这样的序列.. 思路: 因为肯定能看到最高的,,那我们先假定最高的楼房位置确定,那 ...
- 转:requirejs2.0新特性介绍
就在前天晚上RequireJS发布了一个大版本,直接从version1.0.8升级到了2.0.随后的几小时James Burke又迅速的将版本调整为2.0.1,当然其配套的打包压缩工具r.js也同时升 ...
- orcad10.5启动加速
OrCAD不知道怎么滴,启动速度慢的让人崩溃!30秒算快的,有时候甚至几分钟,要么需要连续开N次才打开,苦啊!!经过网上无数文章的洗礼,无数次的尝试,终于得出一种特效方法! 原因:OrCAD启动时在电 ...
- 定制一个winCE5.0操作系统
定制一个winCE5.0操作系统 2009-04-01 09:01:14| 分类: winCE|字号 订阅 定制一个操作系统并模拟器上运行,需要以下几个步骤: STEP 1:用Platfor ...
- OpenStack里对VPN的支持
今天翻自己的笔记找到了点去年研究Cloudpipe的东西: 对于用VLAN隔开的项目内主机的访问,可以使用CloudPipe来进行VPN访问 其实就是把OpenStack和OpenVPN集成了一下,给 ...
- 免费edu邮箱申请注冊地址
几个国外.edu邮箱注冊地址: 注冊地址:http://mail.alumni.fandm.edu/reg/reg_pangia.asp @alumni.fandm.edu 注冊地址: http: ...
- OpenGL ES 如何能看到一个物体内部和象3dmax中能只显示网格线
上一篇 OpenGL ES 正反面设置指令 中分析了正反面的判区方法,那么正反面有什么用呢?接下来我们就要引入一个叫做背面消除的概念.在3dmax中有个选项,当你用挤压修改器挤出一个中空的长方体时,在 ...
- 使用zabbix监控nginx
在zabbix agentd客户端上,查看nginx是否加载了--with-http_stub_status_module.因为zabbix监控nginx是根据 nginx的Stub Status模块 ...