Yet more C abuse
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 also considerably more evil still. I think I've now taken that general idea to somewhere near the limit of its possibilities, by developing a general system of construction-
The result is far too long to fit in this post, so I've put it up on my website. For those with a strong stomach and an interest in metaprogramming or C abuse or both, I present ‘Metaprogramming Custom Control Structures in C’: http://www.chiark.greenend.org.uk/~sgtatham/mp/.
What's the vbKeyCode constant for the {ANY} key?
...Said an Excel developer.
I work on two levels: what's an elegant solution in coding terms; and the ugly questions about how it's actually going to compile and run. The overriding concerns on planet Hairyears are clarity and ease of maintenance - if it was performance, it wouldn't be in VBA! - but sometimes, I need to know what I'm doing, and what's being done for me. And some of *that* is horrible, through and through.
Which in turn means that understanding loops is more than merely coding them, and further reading - like this stuff - is essential.
no subject
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.
no subject
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 :-)
no subject
http://news.ycombinator.com/item?id=3694938
no subject
no subject
forinitialisers) not being available to you.