Path: utzoo!utgpu!attcan!uunet!garfield!john13 From: john13@garfield.MUN.EDU (John Russell) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Message-ID: <4920@garfield.MUN.EDU> Date: 10 Oct 88 23:54:06 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1527@devsys.oakhill.UUCP> Reply-To: john13@garfield.UUCP (John Russell) Organization: Memorial University of Newfoundland Lines: 29 In article <1527@devsys.oakhill.UUCP> steve@oakhill.UUCP (steve) writes: ><1401@devsys.oakhill.UUCP> <8629@smoke.ARPA> >As I pointed out at that time, the use of temp was not optimal. The two >big draw backs are : > 1) It is inefficient. > 2) the use of a temp which must be supplied. 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. Example: consistent double cos(); #define square(x) ((x) * (x)) a = PI / 2.0; b = square(cos(a)); The compiler knows "a" does not change in the expanded expression, so it uses its own temp and only calls cos once. Is this feasible? Doesn't sound too hard... John -- "...and intuition, in a case such as this, is of crucial importance." -- William Gibson, _Count_Zero_