Le 26/10/2012 07:28, Patrick Mueller a écrit : > > On Thu, Oct 25, 2012 at 4:16 PM, Isaac Schlueter <[email protected] > <mailto:[email protected]>> wrote: > It'd be really nice if JS had a way to explicitly delete an object. > > Didn't proxies have some way of doing a become: and freezing > themselves as a new object? Maybe that was the older Proxy stuff, > didn't see it in the current drafts. But did see "Revokable > Proxies", which sounds like it might fit the bill, though you'd > have to arrange to proxy the sketchy object early: > > http://wiki.ecmascript.org/doku.php?id=strawman:revokable_proxies > Indeed. Basically, the revoke functions is a 'free' operator specialized for the generated proxy. Proxies still leaks (that's unavoidable), but the underlying target does not. My original post on the topic (where I mention a use case equivalent to Isaacs') https://mail.mozilla.org/pipermail/es-discuss/2012-August/024344.html
I'm strongy against a free operator, because if it's in a language, it'll be in a node module (or any update...) and people may use it to randomly free objects I created. The module may have been corrupted (by a bug) and the inclusion of a naive free operator would be impossible to defend against. I see an analogy with Dave's post on coroutines [1] (which I think is mistitled because what is said stands beyond the web context). The ability to stop the stack provides authority to library authors that can't be defended against when you import the library and make it harder for you to reason about your program. Generators are a sweet spot between what we expect from coroutines and not providing abusive authority. I think revokable proxies are also a sweet spot between being able to free memory (or rather make memory freeable) and not providing the abusive authority to arbitrarily free anything at anytime. Regarding "it's a problem I have in node.js in production right now!!!", proxies (including the revokable part) have been agreed on by TC39 and are "a V8 issue away" [2] with already a partial implementation (though from the previous design). On the other hand, the "free" operator is meeting resistance on es-discuss (and I assume it won't be agreed on by TC39 as proposed). David [1] http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/ [2] http://code.google.com/p/v8/issues/detail?id=1543
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

