Path: utzoo!attcan!uunet!husc6!rutgers!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs C for computations Message-ID: <3292@lanl.gov> Date: 7 Sep 88 20:31:08 GMT References: <362@quintus.UUCP> Organization: Los Alamos National Laboratory Lines: 41 From article <362@quintus.UUCP>, by ok@quintus.UUCP (Richard A. O'Keefe): > In article <3256@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >>From article <1443@valhalla.ee.rochester.edu>, by davis@galaxy.ee.rochester.edu (Al Davis): > [[ in response to a statement that Fortran is better than C for numerical > work because sqrt() can be trapped in Fortran but not in C, > that it *can* be done in C, with matherr(). > ]] >>Anything C can do portably with library routines, Fortran can also do >>portably with library routines. > > I would like to see a more convincing proof of this. Ok. Take the C library. Write bridge routines through which Fortran programs can call all the procedures in the C library. Fortran now has a library with the same functionality as the C library. QED Obviously - Anything C can do portably with library routines, Fortran can also do portably with library routines. This is because Fortran and C can both use the _SAME_ library on any given machine. > [... lots of stuff about exception handling ...] > How come _the_ language for floating-point calculations doesn't have > a portable way of catching or suppressing floating-point exceptions? Because no two machines have the same exception handling capabilities! In this respect, C, ADA, etc., are not _any_ more portable than Fortran. In fact they are less so since they _require_ particular functionality which the machine may not possess. Some machines, for example, don't have any trap available for underflow. Some systems or hardware (both outside the domain of language definition) put constraints on exception handling. Fortran doesn't include these because there is no portable way to implement them. (The people who ported UNIX to the Crays found a number of unexpected problems of this sort. Some of the assumptions made in the C libraries were _not_ portable.) Note that exception handling was contained in early drafts of the Fortran 8x proposal and failed for many of the same reasons I just stated. J. Giles Los Alamos