first-,second- and third-class value
2013-08-02 09:40
239 查看
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
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
相关文章推荐
- There is no getter for property named 'value' in 'class com.hl.myabtis.first.beas.User'
- <span class="first"></span>为什么不起作用?
- 关于出现this class is not key value coding-compliant for the key的错误
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- this class is not key value coding-compliant for the key digitPressed 解决办法
- HDU 3706 Second My Problem First
- The value for the useBean class attribute XXX is invalid 异常绝对详解释
- addClass(element,value)函数,设置和叠加css样式
- 数据库分析函数 ROW_NUMBER() rank() dense_rank() 的区别 first_value(D) , last_value(D)
- hadoop 的job.setOutputKeyClass和job.setOutputValueClass的几个问题
- setOutputValueGroupingComparator与setOutputKeyComparatorClass
- 数据库-函数-over,row_number,dense_rank,rank,log,lead,first_value等
- hadoop 由job.setOutPutKeyClass和job.setOutPutValueClass引发的键值对输出类型不匹配错误
- Tomcat 常见 "The value for the useBean class attribute is invalid" 错误
- this class is not key value coding-compliant for the key Button 错误解决方法
- The value for the useBean class attribute is invalid 问题
- 详解 Tomcat: The value for the useBean class attribute is invalid 问题
- First and Second Chance Exception
- The value for the useBean class attribute is invalid 问题
- swift4.0 valueForUndefinedKey:]: this class is not key value coding-compliant for the key unity.'