Meaning of "Procedure-valued variable?
What does it meant by a 开发者_如何学Cprocedure-valued variable in the programming language context .
When a variable contains a procedure? Like in functional languages, where you can sth like:
variable f = new function(int x) { return x*2; }
int i = f(3);
I've never heard this term. But from what I've gathered via google (e.g. http://thid.thesa.com/thid-0513-0671-th-1411-0895, http://comjnl.oxfordjournals.org/content/17/1/38.full.pdf), it seems a pretty obscure and old term for or variables of a "callback" or "function" type - a variable that contains a (kind of reference to a) function/procedure.
Most probably, a variable, the value of which is a procedure. Many modern programming languages support this notion. For example, C has function pointers:
void foo()
{
printf("Hello, world!\n");
}
int main()
{
void (*funcp)(void); // pointer to function
funcp = foo;
funcp();
}
Python:
def foo():
print 'Hello, world!'
f = foo // assign foo (a function) to variable foo
f()
精彩评论