3 ms·
You'd prefer explicit "with" clauses even for, say, reference counted types? I mean, Objective-C tried explicit [foo release] for a long time, but I haven't he
by pcwalton 11y ago
You'd prefer explicit "with" clauses even for, say, reference counted types?
I mean, Objective-C tried explicit [foo release] for a long time, but I haven't heard anyone clamoring to go back to the pre-ARC world…
- Animats 11y agoI mean "with" for opens and the like, not structures. Python "with", not Pascal "with". For Python's "with", someone figured out what to do if something goes wrong in __exit__, which is called as control leaves the with clause. An exception in an __exit__ is handled well, and nested exceptions work reasonably. Failure to get this right results in problems such as unnoticed truncated files because the status on the close after a write wasn't checked.
- pcwalton 11y agoRight, I'm referring to Python's "with". How do you write reference counted smart pointers without RAII?