Boost logo

Boost :

From: Chris Lattner (clattner_at_[hidden])
Date: 2007-09-01 21:38:36


On Sep 1, 2007, at 6:32 PM, Andrew Sutton wrote:

>> I agree with Vladimir: my definition refactoring is as a behavior-
>> preserving transformation from one valid program to another. Given
>> this, you really do need much of a compiler, but you also want highly
>> accurate source location information, information about macro
>> expansions, etc which compilers typically don't keep. It's an
>> explicit goal for us to preserve that information and our solutions
>> seem to work well for us so far.
>
> To start with, your definition of refactoring is incorrect - it
> simply preserves the external behavior of a program.

I carefully said it was "my definition" because I'm aware there are
multiple different interpretations. Why do you consider your
definition to be the 'right' one? :)

> I would also
> point out that in order to ensure that a program is correct it first
> has to be preprocessed, and parsed. Something as simple as renaming a
> function - which is a well-known refactoring - requires none of that.

Actually, you're wrong. C and C++ require token pasting and escaped
newline splicing to happen - and they certainly can occur in
identifiers. That is, unless you're willing to break some correct
code, various hacks like using sed can sometimes work... be careful
of scoping issues though, particularly when macros can expand into
{'s :)

> The complexity of the refactoring determines the amount of
> information needed - whether or not you actually need a fully correct
> AST all the time - I doubt it.

Certainly, it obviously depends on the transformation.

-Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk