Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.misc Subject: Re: NOT Educating FORTRAN programmers to use C Message-ID: <15706@haddock.ima.isc.com> Date: 20 Jan 90 02:59:07 GMT References: <12950@cbnewsc.ATT.COM> <14199@lambda.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 30 In article <14199@lambda.UUCP> jlg@lambda.UUCP (Jim Giles) writes: >Fortran allows intrinsic functions to be optimized, C hasn't any intrinsics >(I know, the new standard permits such - show me an available implementation >before you mention it again). Actually, the only difference here between the new standard and the old is the degree of rigor. If you grant that language specs talk about results rather than implementation details, then even pre-ANSI C allows the compiler to inline the library functions (despite the statements in K&R about what one particular compiler happens to do). Anyway, to answer your challenge, gcc can inline the intrinsics. >On the other hand, C can optimize procedure calls (or even 'inline' them) >provided that the procedure and the call are in the same scope (file). >I don't know of any C implementation that actually does this... Both GNU's and AT&T's compilers will do this. >Another example: when writing numerical programs you often need to force the >order of evaluation of an expression to avoid over/underflow or to eliminate >cancellation in subtractions. Fortran (pascal, Modula2, ADA, ...) lets me do >so with parenthesis - C forces me to introduce temporary variables and _hope_ >that the optimizer doesn't actually do a store/load. "Fixed in ANSI C." Also, you're claiming that all implementations of Fortran, Pascal, etc. inhibit optimization around parentheses. I'm not convinced that this has been true in practice. Karl W. Z. Heuer (karl@haddock.isc.com or ima!haddock!karl), The Walking Lint