|
|
|
|
|
Funarg ProblemFunarg is an abbreviation for "functional argument"; in computer science, the funarg problem relates to the difficulty of implementing functions as first-class citizen objects in stack-based programming language implementations. There are two subtly different versions of the funarg problem: - The upwards funarg problem is the problem of passing a function as a value returned "upwards" from a function call
- The downwards funarg problem is the problem of passing a function value as a parameter "down" into another function call
In both of these cases, the problem relates to correctly passing the function's environment together with the function's code. Historically, the upwards funarg problem has proven to be the more difficult. For example, the Pascal programming language allows functions to be passed as arguments but not returned as results; thus implementations of Pascal are required to address the downwards funarg problem but not the upwards one. The C programming language avoids the main difficulty of the funarg problem by not allowing functions to be nested; because the environment of every function is the same, containing just the statically-allocated global variables and functions, a pointer to a function's code describes the function completely. In modern functional languages, functions are first-class values and can be passed anywhere. Thus, implementations of Scheme or SML must address both the upwards and downwards funarg problems. This is usually accomplished by representing function values as heap-allocated closures. Closure-based techniques have proven successful for imperative languages that allow function values as well. In fact, aside from some questions about performance, most language designers do not consider functional arguments a "problem" anymore. See also External link
|
 |
|
| Copyright 2005-2009 OnPedia.com. All Rights Reserved |
|
|