Talk:Closure (computer programming): Difference between revisions

Content deleted Content added
Ruud Koot (talk | contribs)
Line 734:
: I've been think about this for a while, but I'm sure if it possible to explain what a closure is in a single sentence. Do the examples at [[First-class function#Non-local variables and closures]] help you to understand what the purpose of a closure is? If so, they should probably be copied to somewhere near the beginning of this article as well. If not, could you try explain what is still difficult to understand for you?
: Regarding your proposed lead sentence, a closure is not "a function which returns another function". If a functions ''wants'' to return a function it should probably return a closure instead (which is the function begin returned together with some extra data that make it possible for that returned to function to still have access to the variables contained in the returning function's scope.) Cheers, —''[[User:Ruud Koot|Ruud]]'' 19:34, 20 September 2011 (UTC)
:: I'm not sure I follow the examples, but are you just clarifying my lead by saying that a closure is when a function returns a function *while preserving scope*? If so, a closure sounds a bit like a class with a member function... --[[Special:Contributions/204.87.16.4|204.87.16.4]] ([[User talk:204.87.16.4|talk]]) 13:04, 21 September 2011 (UTC)