Talk:Closure (computer programming): Difference between revisions

Content deleted Content added
No edit summary
Wvxvw (talk | contribs)
Line 368:
 
I'm still fuzzy on what a closure is, and I too liked the EcmaScript examples, but I have a very minor beef with one of them. The first example in the [[Closure_(computer_science)#Differences_in_semantics|Differences in semantics]] section confused for an instant. I had read the x = 0 assignment, and I didn't notice the later x =1 assignment. Now, I now this is extremely minor, but I think the readability of the example increases if the initial assignment is x = 1. It seems a bit odd that its done the way it is, and rather than assume that its for no reason, I will assume that maybe I don't understand the reason. That, and my low level of understanding of the topic, keep me from editing myself. Hopefully one of the authors will read this and do the edit or explain the reasons to me (apparently I also need things to be typed slowly &8-P). [[User:Apwith|Apwith]] ([[User talk:Apwith|talk]]) 19:29, 16 October 2009 (UTC)
 
I believe that putting JavaScript examples to illustrate closures is confusing at best. Whatever this article has to say on this matter is questionable. I'm not trying to convince anyone that closures do not exist in JavaScript, but I believe that whenever you are trying to emulate them you are misusing the tool. What you call functions in JavaScript are not the first order functions, they are objects with context and properties. Of course you can say it is not a requirement for the closure to not have either of these, but, normally, you don't want to have them in closure. Besides, the examples given are in general an ill-suggested practice. This is because of how the runtime is implemented and, as I've said, it's just a wrong tool / improper use - it is never a requirement in JS to use this approach, and the alternative approach would always win in terms of code readability and performance. It looks more like if someone wanted very much that closures existed in JS, and some popular libraries, like JQuery or the Closure JS "compiler", make it look like it is there, but, I think we are dealing with the case of where the term is being used improperly to describe something similar, yet not exactly the same. (The need for closures in JS is probably because of wanting to make the code shorter overall, and it is due to the nature of JS - because it should load in the least possible time).<br>
Additionally, earlier on this page I've noted some C# programmer confusion created by Lisp examples, which is understandable, however, it is also strange that JavaScript was suggested as a better illustration, whilst closures are definitely possible in C#, which isn't a less popular language.<br>
[[User:Wvxvw|Wvxvw]] ([[User talk:Wvxvw|talk]]) 20:12, 12 May 2010 (UTC)
 
== What Are Closures ==