|Re: Optimizing Across && And || email@example.com (1995-02-23)|
|Re: Safety and legality of optimizations firstname.lastname@example.org (1995-03-21)|
|Re: Safety and legality of optimizations Vinod.Grover@Eng.Sun.COM (1995-03-28)|
|Re: Safety and legality of optimizations email@example.com (1995-04-03)|
|Re: Safety and legality of optimizations firstname.lastname@example.org (Charles Fiterman) (1995-04-15)|
|Re: Safety and legality of optimizations Dave@OCCL-CAM.DEMON.CO.UK (Dave Lloyd) (1995-04-18)|
|Re: Safety and legality of optimizations email@example.com (1995-04-17)|
|Re: Safety and legality of optimizations firstname.lastname@example.org (1995-04-21)|
|Re: Safety and legality of optimizations email@example.com (1995-04-26)|
|From:||firstname.lastname@example.org (Cliff Click)|
|Organization:||Hewlett-Packard Laboratories, Cambridge Research Office|
|Date:||Mon, 17 Apr 1995 13:28:28 GMT|
Charles Fiterman <email@example.com> writes:
> How about a pure keyword. Pure means this is a pure function. It
> looks at its parameters and returns a value, it has no side effects.
> Calls to pure functions can be lifted out of loops or even done at
> compile time if the right things are known at compile time.
Pure would actually be fairly easy to add to a compiler.
Pure functions are more susceptible to optimizations.
Pure functions need to be compiled with some restrictions:
- only store to local variables (no writes to globals), and
- only call other pure functions.
Another useful keyword might be "only_mods_parms" - only modifies through
parameters or locals. This is a slightly less pure function that can
only modify what is passed by reference to it. A pure function can call
it with pointers to the pure's locals.
In general, making explicit the function domain enables the compiler.
This is especially true for separately compiled functions.
> Note a function that calls error is not strictly pure. Neither is
> a function that memoizes. Pure says this may be used as if it was
> pure. Being able to attach the word to impure functions is the
> best use of pure.
Like "casting away const", casting away pure is fraught with danger and
assumptions about current and future compiler technology. Fortran compilers
routinely know that intrinsics are pure, and at least 1 research compiler
looked at memoizing pure calls.
Cliff Click Compiler Research Scientist
Cambridge Research Office, Hewlett-Packard Laboratories
One Main Street, 10th Floor, Cambridge, MA 02142
(617) 225-4915 Work (617) 225-4930 Fax
Return to the
Search the comp.compilers archives again.