Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!pyrdc!pyrnj!rutgers!att!ihlpl!jhh From: jhh@ihlpl.ATT.COM (Haller) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Summary: avoid new keywords - improve the compilation system Message-ID: <7159@ihlpl.ATT.COM> Date: 12 Oct 88 14:45:21 GMT Article-I.D.: ihlpl.7159 References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1527@devsys.oakhill.UUCP> <4920@garfield.MUN.EDU> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 29 In article <4920@garfield.MUN.EDU>, john13@garfield.MUN.EDU (John Russell) writes: > How about this for an addition to C: a special keyword, similar to const, > which declares that a function which is passed identical values will always > return the same value, and that the function has no side effects. The information to do this is already available, and a truely optimizing compilation system should do this. Note that I said compilation system, not compiler, where a makefile for a product would be the likely input. When compiling cos(), the compiler should be able to take note of there being no side effects, and take appropriate actions if cos is not re-defined within an application. In the example, consistent double cos(); #define square(x) ((x) * (x)) a = PI / 2.0; b = square(cos(a)); the compilation system should be able to detect that 'a' is set from a constant, call cos(a) at compile time, perform the square are compile time, and reduce the fragment to a=1.57..; b=0.0;, all without the need for 'consistent'. This optimization may be beyond the capability of current C compilers, but we should not be introducing new keywords to solve problems that should be solved with compilation technology in the future. John Haller AT&T Bell Laboratories