Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!yale-com!leichter From: leichter@yale-com.UUCP (Jerry Leichter) Newsgroups: net.lang.c Subject: Re: Supporting Structure Comparison Message-ID: <2124@yale-com.UUCP> Date: Wed, 5-Oct-83 09:23:01 EDT Article-I.D.: yale-com.2124 Posted: Wed Oct 5 09:23:01 1983 Date-Received: Fri, 7-Oct-83 03:59:03 EDT References: unc.5972 Lines: 31 One more general approach - which I won't either advocate or criticise, for the moment - has been taken by some compilers (I saw it in some HP compiler): You allow user-defined operator extensions. Thus, if a and b are of type COMPLEX, a + b is compiled as if it was SUM_COMPLEX_COMPLEX(a,b) or some such thing. To really make this usable for things like complex arithmetic, where I would want the complex sum to be expanded in line, it should allow SUM_COMPLEX_COMPLEX to be a macro. Unfortunately, this would be difficult because of the timing of macro expansion and expression parsing; the compiler I saw just generated a function call. The big question involved in such an approach is: Can you keep it small and simple enough to be understandable - and implementable! - while still making it useful? As a quick example of the kind of problem you run into, if a is as above, what should you make of: a + 1 If this calls SUM_COMPLEX_int, you'll end up having to write a LOT of functions just to get things off the ground; if it calls SUM_COMPLEX_COMPLEX, things will get very confused. -- Jerry decvax!yale-comix!leichter leichter@yale