Talk:Closure (computer programming): Difference between revisions

Content deleted Content added
m subst:'ing and swapping unsignedIP for unsigned where appropriate using AWB
Geira (talk | contribs)
Line 14:
 
: I totally disagree with starting with a language other than lisp. Closures originated with Lisp. Many programming languages that claim to support closures - for example Java, Javascript, C#, Python - actually don't support full closures for one reason or another. Scheme and Smalltalk are the best examples of imperative languages that do support closures. [[User:Gafter|Gafter]] 15:48, 10 December 2006 (UTC)
 
:: Then you should at least be sure what kind of closures you are talking about. The opening reference to [[Structure and Interpretation of Computer Programs]] is totally misplaced - the authors are talking about [[Closure (mathematics)]], not [[Closure (computer science)]] (e.g. the cons of a list is itself a list [http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#%_idx_1532]). This is explained quite clearly in this footnote to chapter 2.2:
 
::: <i>The use of the word "closure" here comes from abstract algebra, where a set of elements is said to be closed under an operation if applying the operation to elements in the set produces an element that is again an element of the set. The Lisp community also (unfortunately) uses the word "closure" to describe a totally unrelated concept: A closure is an implementation technique for representing procedures with free variables. We do not use the word "closure" in this second sense in this book.[http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#%_idx_1536]</i>
 
:: Anyway, while lots of nifty things originated in Lisp, I find it hard to think of closures without lexical scoping, and Lisp didn't get that until 1984. [[User:Geira|Geira]] ([[User talk:Geira|talk]]) 19:01, 4 February 2008 (UTC)
 
:: That's not correct WRT JavaScript. JavaScript does support closures in every sense of the word. And a tip o' the hat to [[User:Int19h]] for adding the JavaScript examples. Because so many programmers can read JavaScript, it is an excellent language for showing examples of closures. --[[User:Geary|Michael Geary]] 17:53, 26 January 2007 (UTC)