[R] What is a 'closure'?
peter dalgaard
pdalgd at gmail.com
Thu Jan 19 22:19:52 CET 2012
On Jan 19, 2012, at 21:39 , Ben Bolker wrote:
> Ajay Askoolum <aa2e72e <at> yahoo.co.uk> writes:
>
>>
>> Michael, thank you, especially for the link. I think I understand.
>>
>> The vocabulary is so different! I know 'closure' as 'user-defined function'.
>>
>
> Not quite. All (??) user-defined functions are closures, but lots
> of non-user-defined functions are closures too ...
>
Also, it is not actually the function that is the closure, it is the function completed with its environment, which is where, during evaluation, unbound objects will be sought.
The function itself is a parsed version of the function definition. When called, almost all functions will need to find something from their environment, e.g. the "<-" operator. The only functions that are completely self-contained are those that return a constant or one of the function arguments (maybe a few more).
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list