4 ms·
It's not clear to me how / if this works with closures. I expected that it would be part of a block initializer. e.g. `using x { /* scope where x exists */ } /
by kybernetikos 3y ago
It's not clear to me how / if this works with closures.
I expected that it would be part of a block initializer. e.g. `using x { /* scope where x exists */ } /* x was disposed when the block ended */`. This would also make it clearer that it can work even without assignment or with destructuring assignment (the outer object is disposed after the block even if it is not used).
I wonder why they decided not to do it like that.
- brundolf 3y agoCame here to ask the same question
- wvenable 3y agoC# has that syntax for using (the using block) but it's slowing being phased out in favor the using statement like this. It's a big cleaner and closer to the needs of the programmer this way. It's not much different then let -- you're defining a block scoped variable that just happens to call the dispose symbol function when the block ends.
- Dylan16807 3y ago> It's not clear to me how / if this works with closures. If you elaborate on what working with closures and not working with closures would look like, I could try to answer that.