HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Does the closure of a function include the actual parameter passed to the function?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
theactualincludepassedfunctiondoesclosureparameter

Problem

A closure of a function includes the environment when calling the function.

Does the environment included in a closure of a function include the actual parameters for the function?

If I am correct, from mathematical logic point of view, a closure for an expression consists of the free variables of the expression. So I guess the answer to the question is no.

Solution

No. A closure is a function, and, as such, its parameters are passed when the function is called. The main difference between closures and plain functions is that closures are associated with an environment. This environment stores the values of the free variables* that were in scope when the function was created.

* The term free variable refers to those variables which are used locally within a function but are defined outside of this function (i.e., in an enclosing scope).

Context

StackExchange Computer Science Q#63427, answer score: 5

Revisions (0)

No revisions yet.