From: Baptiste L. <gai...@fr...> - 2003-01-07 08:37:31
|
----- Original Message ----- From: "Andre Baresel" <and...@gm...> To: "Baptiste Lepilleur" <gai...@fr...> Sent: Friday, December 27, 2002 8:57 PM Subject: Re: [Cpptool-develop] Progress on InlineTemp > Baptiste Lepilleur wrote: > > >----- Original Message ----- > >From: "Andre Baresel" <and...@gm...> > >To: "CppTool Mailing List" <Cpp...@li...> > >Sent: Friday, December 27, 2002 11:38 AM > >Subject: [Cpptool-develop] Progress on InlineTemp > > [...] > >I don't get what you mean. Do you mean if the variable is initialized by a > >constructor ? > > > nope this will be detected as not allowed at the moment since it > contains an identifier. > However just two examples: > > int tmpTobeInlined = 3; > expr = tmpTobeInlined * 5; > ==> Here we have no problem just replacing the tmpToBeInlined by its > initializer resulting in: > expr = 3 * 5; > > But what about: > int tmpTobeInlined = 3 + 3; > expr = tmpTobeInlined * 5; > ==> Here we have to add braces for the expression "3 + 3" resulting in: > expr = (3 + 3) * 5; OK, I understand what you mind. That the kind of stuff you don't see until you tackle the refactoring. > For that reason I'm currently adding allways braces which doesn't look > very nice for most usecases I believe: > expr = ( 3 ) * 5; > With some Code-Rewriter that knowns about minimal placement of braces > that would be no problem. I don't believe removing the braces should be done after. It would be very tricky to distinguish between brace added by the user for clarity and those added by the tool. There should be a way to say weither or not the braces are required, though it promise to be tricky anyway. > I was just thinking about an heuristic for the decision of placing > braces: > Just check if any c++ operator occures in the blanked text of the > initializer. If it does, I will place braces, if not > I leave it as it is. This sound good. Baptiste. > > -- Andre |