Unnecessary Macros (was Re: Unnecessary Parenthesis)

John Gateley gateley at mips.csc.ti.com
Sun Oct 2 04:38:27 AEST 1988


In article <956 at l.cc.purdue.edu> cik at 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 at mips.csc.ti.com



More information about the Comp.lang.c mailing list