Am 18.11.2014 um 22:03 schrieb Brendan Eich: > Christian Mayer wrote: >> What I actually sometimes really miss in JavaScript (having a big C++ >> background) are destructors. >> >> (I haven't checked if they are in any new version proposal, though) > > No, as JS has no stack storage class, only we-hope-unobservable GC, no > destructors.
I fully understand that something called at GC time won't work - but that's not a real destructor for me, that would be a sort of "destroyer"... :) The destructor should IMHO be called when the JS internal ref count gets to 0, i.e. when the object gets released to the GC to do it's job when it wants to. (This could actually be generalized by offering a callback function that gets called every time the internal refcount gets decreased... The current ref count could be passed as a parameter then) One very obvious use case for me would be debugging and making sure that my objects aren't leaking. But anything could make sense where destructors are usually used for. _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss