anything like C++ references?

Tim Peters tim.one at comcast.net
Thu Jul 17 20:28:09 CEST 2003


[Stephen Horne]
>> Anyway, Algol and Fortran apparently (I didn't know this until today)
>> *always* used call-by-reference.

[Terry Reedy]
> Not true (about Fortran).  I vaguely remember (about 1980) when IBM
> Fortran switched from one calling convention to another.  I initially
> missed the one-line change in the manual update sheets.  A working
> program started giving strange results until I finally figured out
> what was going on and then found the one line 'announcement'.

Yes, many Fortran implementations used call-by-value/result, and that's fine
by Fortran's rules.  The primary difference lies in whether assigning to
formal argument X appeared to change the value of formal argument Y too,
while you were still in the subroutine with those formal arguments, when the
caller passed the same variable as actual argument in both the X and Y
positions.  In CBR, changes are instantly visible via aliases; in CBVR,
they're not.  The Fortran standard finessed this simply by declaring
programs which relied on either specific behavior to be non-conforming
programs ("undefined").

Algol's history is a lot more complicated too, and, indeed, the infamous
"call by name" came out of what was probably a mistake in the Algol 60
specification.






More information about the Python-list mailing list