D - Re: scope of variables in do-while
- Tony West <Tony_member pathlink.com> Jan 07 2004
- Ilya Minkov <minkov cs.tum.edu> Jan 07 2004
I've had the same problem and yes, it would be nice for the scope to extend to the while expression. I would imagine that this is not normally supported because of the possibility that an identifier may be redefined within an inner block, e.g. int a; do { int a; blah... }while (a == 1); Which "a" is referenced within the while expression? Fortunately, since D does not allow multiple definitions, this should not be an issue. Tony
Jan 07 2004
Tony West wrote:int a; do { int a; blah... }while (a == 1);
Such a loop is a nonsense anyway, since it either loops only once, or never stops, depending on the value of outermost a. That's most probably not what the average coder wants when he writes that. -eye
Jan 07 2004