🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2474

Re: Fortran vs. C for numerical work

#2474
From: Bruce.Hoult
Date: Mon, 10 Dec 1990 07:00
59 lines
2829 bytes
In article <13552@chaph.usc.edu> jeenglis@alcor.usc.edu (Joe English Muffin) writes:

>>   IF(a) 1111,1112,1113
>>1111   b = sqrt(-1.0*a)
>>   GO TO 1114
>>1112   b = 0
>>   GO TO 1114
>>1113   b = sqrt(a)
>>1114   CONTINUE
> 
>Sure, you can also do this in C:
> 
>    if (a < 0.0) goto label1;
>    else if (a > 0.0) goto label2;
>    else if (a == 0.0) goto label3;
>    else exit(1);
>label1:     b = sqrt(1.0 * -a); goto label4;
>label2:     b = sqrt(1.0 * a) ; goto label4;
>label3:     b = sqrt(1.0 * 0.0); goto label4;
>label4:     ;
> 
>What's your point?

The point was that a FORTRAN user was complaining about the obscurity of
the ? : construct in C, and I was pointing out tha tthe FORTRAN arithmetic
GO TO wasn't much better.



>>>  another reason (vms-specific) is that vms C uses the CALLS instruction
>>>to jump to a subroutine, as compared to fortran using CALLG.  
> 
>>In C or Pascal you could allocate a structure as a global (static) variable,
>                                                    ^^^^^^^^^^^^^^
>To allow recursion, the compiler would have to allocate this
>as 'auto,' in the caller's stack frame.
 
I don't think you read the original posting.  The point I was replying to was
that in FORTRAN the compiler can generate more efficient code because there
was no need to allow for recursion.  My point was that if you disallow
recursion then Pascal or C could do virtually as well.

Your saying "To allow recursion, the compiler would have to..." is hardly a
refutation of something which has assumed that recursion *isn't* happening.


>>assign your parameters into it and just pass a pointer to the structure to
>>the called routine.  The compiler might even be smart enough to use CALLG,
>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>Probably not.  Since there's always the possibility that the
>function will be called from somewhere without a prototype in
>scope, parameter block argument passing wouldn't be a feasible
>scheme.

I don't understand this remark.  Could you explain it?
-- 
Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 772 116
BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
Technical Details
Message-ID: <1990Dec10.070017.19821@actrix.gen.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult
References: <77124@iuvax.cs.indiana.edu> <1990Dec9.040635.12696@actrix.gen.nz> <13552@chaph.usc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult
From: Bruce.Hoult@bbs.actrix.gen.nz
Newsgroups: comp.lang.misc
Subject: Re: Fortran vs. C for numerical work
Message-ID: <1990Dec10.070017.19821@actrix.gen.nz>
Date: 10 Dec 90 07:00:17 GMT
References: <77124@iuvax.cs.indiana.edu> <1990Dec9.040635.12696@actrix.gen.nz> <13552@chaph.usc.edu>
Sender: Bruce.Hoult@actrix.gen.nz (Bruce Hoult)
Organization: Actrix Information Exchange, Wellington, New Zealand
Lines: 59
Comment-To: jeenglis@alcor.usc.edu