General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
gingerBill
ThePrimeTime
comments
Comments by "gingerBill" (@GingerGames) on "New Keyword "using" in JavaScript!" video.
Why are they going the pseudo-destructor route rather than just having an explicit `defer`? The Drop trait makes sense in Rust due to its ownership+lifetime semantics, but does this `using` idea actually make any sense in JS? Why would `defer` be a bad idea? (I know `defer` is kind of already a thing for `<script defer ...>` but that's not technically JS at that point). let resource = getResource(); defer resource.dispose(); // or defer await resource.dispose(); This is just objectively clearer, even if you have to type an extra-line (oh no, not another line(!) /s). It would work with everything else already too that doesn't have the Symbol.dispose/asyncDispose nonsense too.
3
@eugenakv I use scope-based `defer` in other languages all the type for many things which are not "destructors" whatsoever. A good example are any calls that are effectively in nature begin/end, open/close, increment/decrement, etc, most of which have nothing to with type construction.
2