Chris Angelico wrote: > On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__pete...@web.de> wrote: >> Why would you guess if you can check? Just fire up the interactive >> interpreter^W^W compiler: > > Partly because there's a difference between valid C++ and valid input > to the G++ compiler :) Knowing that it works with g++ doesn't tell me > that it's actually valid, and I don't feel like digging into the specs > to find out where you're guaranteed to be allowed to do that. (I could > probably test it with one of the language spec options, but then it > still depends on the exact version of GCC and the exact spec chosen.)
I don't have the spec handy, only an old copy of "The C++ Programming Language" which has """ To avoid accidental misuse of a variable, it is usually a good idea to introduce the variable into the smallest scope possible [and] to delay the definition of a local variable until one can give it an initial value. [...] One of the most elegant applications of these two principles is to declare a variable in a condition. Consider: if (double d = prim(true)) { left /= d; break; } """ -- https://mail.python.org/mailman/listinfo/python-list