gerald_duck |
Mon 2012-03-12 22:20 |
You mention C++, but surely these shenanigans (fascinating in their twistedness though they may be) belong entirely in the land of C?
In the first place, C++ entirely solves the problem of tidying away resources that go out of scope in a rather more thorough way. And, for that matter, iterators allow non-standard behaviours to be packaged in a for-loop-friendly way. (Even more friendly for C++11's range-based for loops.)
In the second, the combination of exceptions and C++'s somewhat necessary prohibition on jumping past a non-trivial constructor or destructor invocation make the idiom unusable in some cases and dangerous in others. |
|