home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!burley
- From: burley@geech.gnu.ai.mit.edu (Craig Burley)
- Newsgroups: comp.lang.fortran
- Subject: Re: Small Language Wanted
- Message-ID: <BURLEY.92Aug28115438@geech.gnu.ai.mit.edu>
- Date: 28 Aug 92 15:54:38 GMT
- References: <9224107.5975@mulga.cs.mu.OZ.AU> <17jmqfINNmrc@network.ucsd.edu>
- Sender: news@ai.mit.edu
- Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139
- Lines: 60
- In-reply-to: mbk@lyapunov.ucsd.edu's message of 27 Aug 92 23:00:31 GMT
-
- In article <17jmqfINNmrc@network.ucsd.edu> mbk@lyapunov.ucsd.edu (Matt Kennel) writes:
-
- How does C know when compiling foo.c the difference :
-
- cc -c foo.c
- cc -o foo foo.o -lm
-
- vs.
-
- cc -c foo.c
- cc -c pow.c
- cc -o foo foo.o pow.o -lm
-
- ???
-
- Or is this a resolved problem?
-
- It's resolved, in essentially the same way as:
-
- prog.f:
- PRINT *,MAX(3,4)
- END
-
- max.f:
- INTEGER FUNCTION MAX(I,J)
- MAX = I+J
- END
-
- g77 -c prog.f
- g77 -o prog prog.o ...
-
- vs.
-
- g77 -c prog.f
- g77 -c max.f
- g77 -o prog prog.o max.o ...
-
- In Fortran, the lack of "EXTERNAL MAX" or equivalent means you've referred
- to MAX the intrinsic in prog.f, independent of whether you've got an external
- function named MAX. In C, the use of "#include <math.h>" means you've
- referred to the "built-in" pow(), independent of whether you've got an external
- function named pow(). Of course, C doesn't have to keep the built-in names
- separate from the external names like Fortran, so in Fortran you can always
- be sure that prog.f invokes MAX the intrinsic while other program units could
- still invoke MAX your external function, while in C, you might or might not
- get away with that, depending on the system you're using (i.e. it's not
- portable).
-
- Question: Do you know which real live C compilers that people can buy or
- steal which do in fact perform the optimizations that we're talking about?
-
- Well, I know GNU C has code to replace things like memcpy() with machine
- code, sometimes depending on things like small amount of data being copied,
- so it could use the same mechanism to handle pow() if it wanted. But I haven't
- looked at this for some time. And I don't know if that code is enabled on any
- machines anyway, though it might be.
- --
-
- James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
- Member of the League for Programming Freedom (LPF)
-