|
|
|
|
|
by deathanatos
1769 days ago
|
|
defer (/using/with) all require the programmer to remember, and write, O(use site) times, the code to release the resource. RAII destructors, on the other hand, do not permit the coder (at the use site of the type) to forget, as the destructor is invoked automatically when the variable goes out of scope. In my time reviewing Python (also GC, "with" provides a similar functionality), this is a very common error. |
|
Same applies to using on .NET, where forgetting to call using on an IDisposable type can trigger a compiler error, via Roslyn plugins.
Also seem to be unaware how closure based RAII works on FP languages.
RAII isn't triggered on heap allocated objects unless smart pointers are used everywhere.
Python doesn't have a static analysis tool for with, nor does it support value types with stack allocation. Not all GC languages were born equal.