|Q: Side effect removal transformations (Source to source) email@example.com (1995-04-12)|
|Re: Q: Side effect removal transformations (Source to source) firstname.lastname@example.org (1995-04-18)|
|Re: Q: Side effect removal transformations (Source to source) email@example.com (1995-04-28)|
|From:||firstname.lastname@example.org (Max Copperman)|
|Organization:||Rank Xerox Research Centre - Grenoble Laboratory|
|Date:||Fri, 28 Apr 1995 18:58:02 GMT|
email@example.com (Mark Harman) writes:
> The transformations I'm looking for would transform a C program with side
> effects in its expressions into a semantically equivelent program (in C) with
> no side effects.
In the general case you can't do it, because the order of evaluation is not
fixed. There are sequence points, but in between two sequence points the
language does not define evaluation order. Consider foo(i++) where i is
global and used within foo().
A program with evaluation order dependencies has is semantically ambiguous
between the semantics of each possible evaluation order. You can't
represent more than one evaluation order in a program with no side
effects, thus it would take multiple no-side-effect programs to
represent the semantics of an evaluation-order-dependent program.
Chances are a program with evaluation order dependencies is buggy, unless
it is an example for a programming language class.
As far as how to do the transformations, you might try looking for
papers on Single Assignment (or Static Single Assignment) languages.
Return to the
Search the comp.compilers archives again.