🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #835

Re: NOT Educating FORTRAN programmers to use C

#835
From: Jim Giles
Date: Tue, 23 Jan 1990 23:43
42 lines
2367 bytes
From article <4540@scolex.sco.COM>, by seanf@sco.COM (Sean Fagan):
> [...]
> 	x[i] = x[i] + foo();
> vs.
> 	x[i] += foo();
> where one or more of x and i are global.  Oops.  If your FORTRAN copmiler
> optimizes that away, you quite probably, have some problems.

If the function evaluation changes either x or i in the above, the Fortran
version of " x[i] = x[i] + foo()" would be illegal!  This is not perfect
either and the Fortran version would have to introduce an intermediate
variable to store the function result.  However, if any of your C programs
rely on the above distinction, it is likely to be a source of errors
anyway.  Most advocates of "structured programming" recommend against
fuctions with side-effects at all.  As a practical matter, such functions
require more careful treatment regardless of language.

This is not to say that I agree with the Fortran restriction.  I think
the above assignment should be legal and the user should be allowed to
control whether optimization is performed or not by declaring whether
the function has side-effects or not.  Neither C nor Fortran currently
has this feature.

> [...]
> Some of Jim's points have merit.  However, he does not really seem to know
> what's available in C compilers today,

True, I don't know the whole C market.  I only know what the C compilers
avaliable to ME are capable of doing.  Further, most C supporters in this
discussion don't seem to know what available Fortran implementations do
(I haven't been limited to 6 char identifiers for over a decade).

> [...]                               nor what the C standard (no longer a
> draft!) says, which kinda hurts his arguments.

Just because C has been approved doesn't mean general availability.
C supporters don't know what Fortran 90 offers either - why should they?
Fortran 90 is on the verge of approval (within a few months most likely)
but it won't be widely available for a while yet.  I don't claim that
your ignorance of Fortran 90 hurts your argument.

J. Giles
Technical Details
Message-ID: <14206@lambda.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!lambda!jlg
References: <4540@scolex.sco.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!lambda!jlg
From: jlg@lambda.UUCP (Jim Giles)
Newsgroups: comp.lang.misc
Subject: Re: NOT Educating FORTRAN programmers to use C
Message-ID: <14206@lambda.UUCP>
Date: 23 Jan 90 23:43:19 GMT
References: <4540@scolex.sco.COM>
Lines: 42