3 ms·
Would it be better to have to explicitly declare what variables you want to import into the closure like PHP or C++ do? C# also captures everything by default a
by maxxxxx 9y ago
Would it be better to have to explicitly declare what variables you want to import into the closure like PHP or C++ do? C# also captures everything by default and reference which has tripped me up quite a few times.
- jhgb 9y agoThat might help but it seems like either an implementation or language spec fix is in order. There doesn't seem to be a reason for a function without free variables to turn into a closure at all, thus preventing the issue.
- paulddraper 9y agoYep. Currently, the ECMAScript specification says nothing about GC. And it seems every major JS engine has decided that this type of memory leak is okay. So it's rather unlikely something will change.