От: | _NN_ | www.nemerleweb.com | |
Дата: | 14.05.18 19:52 | ||
Оценка: |
_>Michael L. Scott, Programming Language Pragmatics, 3-rd ed., ELSEVIER 2011
_>ISBN 13: 978-0-12-374514-9
_>Page:154
_>3.6.2 First-Class Values and Unlimited Extent
_>In general, a value in a programming language is said to have
_>first-class status if it can be passed as a parameter, returned from a subroutine, or assigned into a variable.
_>Simple types such as integers and characters are first-class values in most programming languages.
_>By contrast, a
_>“second-class” value can be passed as a parameter, but not returned from a subroutine or assigned into a variable,
_>and a
_>“third-class” value cannot even be passed as a parameter.
first-class status if it can be passed as a parameter,
#include <iostream>
#include <memory>
using namespace std;
void f(auto) {}
int main()
{
f([]{});
}
returned from a subroutine, or assigned into a variable
#include <iostream>
#include <memory>
using namespace std;
auto f() { return []{return 1;}; } // returned from a subroutine
int main()
{
auto l = f(); // assigned into a variable
return l();
}