[nem-en] On unreachable code inside macro generated code
Tanton Gibbs
tanton.gibbs at gmail.com
Wed Aug 30 22:24:49 CEST 2006
> This spotted giving me warnings. Only later I finally understood that
> it is actually incrementing code inside of foreach generated code that
> becomes unreachable: the code that is supposed to execute after doing
> `found(true)', which will of course never happen. There are also some
> other situations where I wanted to use `code only for first element'
> with foreach, for example:
I realize I'm new to this list, so please take what I say with a grain
of salt. However, it seems to me that you shouldn't use foreach to
find the first element that matches some predicate, so the error is,
in fact, a good thing. I would rather see a find() or find_first_of()
function or macro to do that sort of thing. To me, using foreach
implies iterating over all the elements, not stopping midstream.
Thanks!
Tanton
More information about the devel-en
mailing list