From: Baptiste L. <gai...@fr...> - 2002-11-29 21:55:27
|
I finally added scope support for RenameTemp. It's seems to work just fine: { double x = getPrice(); x += x * rate; if ( needTaxes() ) { int x = x * taxeRate; setTaxes( x ); } return x * getQuantity(); } Is correctly refactored to (rename the first occurence of x to price): { double price = getPrice(); price += price * rate; if ( needTaxes() ) { int x = price * taxeRate; setTaxes( x ); } return price * getQuantity(); } Things are really looking good... Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/ |
From: Sven R. <rei...@ma...> - 2002-11-30 15:59:17
|
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... |
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... |
From: Baptiste L. <gai...@fr...> - 2002-12-01 21:34:34
|
It's fixed. Baptiste. ----- Original Message ----- From: "Baptiste Lepilleur" <gai...@fr...> To: "Sven Reichard" <rei...@ma...>; "CppTool Mailing List" <Cpp...@li...> Sent: Sunday, December 01, 2002 10:25 PM Subject: Re: [Cpptool-develop] RenameTemp now support scope > 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... > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Cpptool-develop mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cpptool-develop > > |