C optimizer

Jeff A. Bowles bowles at eris.berkeley.edu
Wed Feb 15 02:48:06 AEST 1989


In article <13134 at steinmetz.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>  I agree. One solution would be to provide a keyword, perhaps something
>like 'pure' or 'deterministic', which would indicate that a procedure
>always returns the same value for a set of given arguments. Note that
>this is not the same thing a "no side effects," my intent is only that a
>second call with the same arguments would not change the side effects
>(such as saving one of the arguments, etc).

One language I read about in ages past had the notion of function versus
procedure as defined below:
	function: Like a mathematical function, is strictly a function of
		  its arguments. (Perhaps the arguments might be put through
		  a "known" transformation, like a table lookup, but this
		  idea tends to support the notion that a set of inputs gives
		  the same output, consistently.)
	subroutine: fair game.

Now, in C, it's harder than you think - because if you pass a pointer to
a procedure, it's difficult to keep the procedure from modifying data to
which the argument points. Notions like "const" and function prototypes
make it a little easier to decide what a procedure DOESN'T do, but it's
pretty hard to tell if a procedure will fit the definition of a "function"
above.

	Jeff Bowles
case 



More information about the Comp.lang.c mailing list