Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!rutgers!bellcore!tness7!killer!pollux!ti-csl!mips!gateley From: gateley@mips.csc.ti.com (John Gateley) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Message-ID: <60009@ti-csl.CSNET> Date: 1 Oct 88 18:38:27 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> <1851@loral.UUCP> <956@l.cc.purdue.edu> Sender: news@ti-csl.CSNET Reply-To: gateley@mips.UUCP (John Gateley) Organization: TI Computer Science Center, Dallas Lines: 17 In article <956@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >What is needed is something like >#define fc(x,y) (LOCAL tmp1,tmp2; tmp1=x; tmp2=y; fc(x,y)=tmp1*tmp1+tmp2*tmp2) >which should be interpreted correctly even if x or y happens to be tmp1 or tmp2. >I do not know to what extent compiler implementations do this, but I doubt >that a #define is treated other than a macro expansion, and I do not see >how the problem can be avoided without something like this. The ONLY place I have heard of this being done for macros is in the programming language Scheme: using Eugene Kohlbecker's et al. beta-expansion macro expander, or more recently Johnathon Rees's syntactic closures. I think you are out of luck with C. What might help is a generate symbol operation. This should give you a brand new symbol each time it is called. You might be able to fake it in C somehow. John Gateley gateley@mips.csc.ti.com