From: Baptiste L. <gai...@fr...> - 2002-12-01 21:20:25
|
You're right. I checked with VC++ and the variable is indeed accessible in the initializer. This sound plain wrong for me, but that the way it is. Should be fairly simple to correct though. Baptiste. ----- Original Message ----- From: "Sven Reichard" <rei...@ma...> To: "CppTool Mailing List" <Cpp...@li...> Sent: Saturday, November 30, 2002 4:59 PM Subject: Re: [Cpptool-develop] RenameTemp now support scope > Looks great. However, I think the code below is incorrect, if I understand > the grammar correctly. Stroustrup says something like: The scope of a > name starts at the point of its declaration; i.e., after the complete > declarator and before the initializer (Stroustrup, 4.9.4, translated back > from German). That means that in the line > > int x = x * taxeRate; > the second x already refers to the new variable, i.e., its uninitialized > value. So, it should be left unchanged, rather than being refactored to > > int x = price * taxeRate; > This is just my theoretical understanding; I'll check if the compiler > understands the standard in the same way. If this is true, it should make > the refactoring even easier. > > Sven. > > -- > Sven Reichard > Dept. of Math. Sci. > University of Delaware > rei...@ma... |