Another 'D' proposal (sigh)

Frank Adams franka at mmintl.UUCP
Wed Mar 2 06:58:40 AEST 1988


In article <2230 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <1893 at phoenix.Princeton.EDU> rjchen at phoenix.Princeton.EDU (Raymond Juimong Chen) writes:
>>Propose that there be a way to declare "true functions", ie, functions
>>whose return values depend on and are solely determined by the arguments
>>passed to it.  They also have no side-effects.
>Declaring such functions is like using noalias--the compiler cannot
>easily confirm that what the programmer claims is really true.
True, but the compiler can easily check for a set of conditions which is
sufficient for a function to be a "true" function, and issue a warning if
these are not met.  Basically, the function may not access global or static
variables, call any non-true functions, nor dereference a pointer.  (I may
be missing some conditions here.)  This will cover a significant fraction of
the functions in this category.  (Particularly if we ignore the C "arrays
are pointers" confusion.)

Actually, I was thinking about this just the other day.  I'm still not
convinced that it is sufficiently useful to be included.  Does anyone have
any data on how many function calls a good compiler can eliminate by such a
feature?
-- 

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Ashton-Tate          52 Oakland Ave North         E. Hartford, CT 06108



More information about the Comp.lang.c mailing list