-> You're right, that is a useful thing sometimes. The discussion was
started
-> when someone (forget who now :-) suggested or implied that subroutine
-> arguments might should be passed by reference as a default, and
function
-> arguments be passed by value as default. I responded with a speculative
-> "off the top of my head" message about "would it be a good idea?",
while
-> several others responded to the original message and mine in various
ways,
-> and that's how we got here. :-)
-> I don't think anyone here has suggested that arguments should always be
-> passed in only one way.
I guess I am content with BASIC's habit of passing variables by
reference since, as far as I can recall, it has never caused me any
trouble. Sure, it is theoretically possible to write code that
misbehaves when an altered value of a SUB argument gets passed back to
a calling routine, but in practice I have never seen this happen. On
the other hand, I have many times written code in which this feature of
BASIC is put to good use. So its advantages (many) outweigh its
disadvantages (none).
Of course, it is easy to make BASIC pass parameters by value by writing
them as arithmetic expressions, rather than single variables:
CALL Routine (X + 0)
Even if Routine changes the value of its input parameter, the value of
X in the calling routine is unaltered. I don't think I have ever done
this in practice, but I can see that it might sometimes be useful.
dow


|