which language allows you to change an argument's value?
John W. Kennedy
jwkenne at attglobal.net
Sat Oct 6 18:08:53 EDT 2007
Roedy Green wrote:
> On Sun, 30 Sep 2007 10:47:13 -0000, Summercool
> <Summercoolness at gmail.com> wrote, quoted or indirectly quoted someone
> who said :
>> and now n will be 3. I think C++ and PHP can let you do that, using
>> their reference (alias) mechanism. And C, Python, and Ruby probably
>> won't let you do that. What about Java and Perl?
> Seem to me you could in FORTRAN and Pascal, and maybe even Algol.
FORTRAN generally looked like call by reference, but was often actually
implemented element variables as copy-in at call time and copy-out at
return time. In standard older FORTRAN, the effective results were the
same. I don't know how things stand with modern Fortran, where some new
features have made the assumption that copy-in-copy-out is equivalent to
reference more dangerous. Ada is /defined/ as using copy-in-copy-out for
element variables.
ALGOL had a weird "by name" convention. The semantics were essentially
that, for each argument, a closure (historically called a "thunk") was
constructed, and every time the parameter was referenced, the
corresponding closure was called. Theoretically elegant, but hideous to
implement, and with bizarre side-effects in certain cases.
--
John W. Kennedy
Read the remains of Shakespeare's lost play, now annotated!
http://pws.prserv.net/jwkennedy/Double%20Falshood/index.html
More information about the Python-list
mailing list