Thanks for the thorough reply. On Sep 27, 6:13 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > Hi, > > > The author of coffeescript mentioned on this thread (http://github.com/ > > jashkenas/coffee-script/issues/issue/675/#issue/675/comment/402197) > > that ie leaks memory if you use named functions, instead of closures. > > IE doesn't leak memory if you use named functions (or at least, I've > never heard of it doing so). I'm pretty sure jashkenas was talking > about a bug IE has related to named function *expressions*, which are > a different thing. Prototype doesn't use any named function > expressions. > > Here's a named function declaration: > > function foo () { > > } > > Here's a named function *expression*: > > var f = function foo() { > > }; > > The difference being that you're using the function as a right-hand > value in an expression. (A right-hand value is the value to the right > of an = in an assignment, to the right of a : in a property > initializer, or that you pass into a function when calling it.) > > The short version of the bug is that IE will create two near-identical > functions instead of one if you use a named function expression. This > is wrong, and of course it means that IE uses double the memory it > should have, but it isn't a memory "leak" in the sense of ever- > increasing memory usage. Another aspect of the bug is that the symbol > `foo` gets defined in the containing scope, which is incorrect. > > For more details, it happens that I just recently wrote this up > (although the bug has been around > forever):http://blog.niftysnippets.org/2010/09/double-take.html > > IE isn't the only browser that has (or has had) issues with named > function expressions. kangax wrote up a very useful article a while > back on what NFEs are and how they get treated by various versions of > various JavaScript engines. The article is a couple of years old now > and the most recent implementations of many engines do better, though > not IE's JScript:http://kangax.github.com/nfe/ > > Slightly off-topic, but you said "...named functions, instead of > closures...". Named functions *are* closures. Whether the function > has a name doesn't affect whether it closes over data. More about > closures > here:http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html > > HTH, > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com > > On Sep 27, 3:01 am, Daniel Ribeiro <dan...@gmail.com> wrote: > > > The author of coffeescript mentioned on this thread (http://github.com/ > > jashkenas/coffee-script/issues/issue/675/#issue/675/comment/402197) > > that ie leaks memory if you use named functions, instead of closures. > > If this is true, why does Prototype uses some of these (such as > > function $A onhttp://prototypejs.org/assets/2009/8/31/prototype.js)?
-- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.