In two
recent posts here, I've suggested moderately evil things to do with the C preprocessor, both on the same theme of defining a macro that can be used like a loop keyword by following its invocation with a statement or block of your choice.
Last week some further thoughts on the subject occurred to me, which were rather more comprehensive and
(
Read more... )
Comments 5
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.
Reply
It's true, of course, that if you're writing a program that's actually allowed to use C++ features then you probably want to be doing an entirely different set of horrifying language abuses :-)
Reply
http://news.ycombinator.com/item?id=3694938
Reply
Reply
Reply
Leave a comment