Re: Call by Reference



On Oct 23, 8:02 am, Andreas Leitgeb <a...@xxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Joe English <jengl...@xxxxxxxxxxxxx> wrote:
Andreas Leitgeb wrote:
Gerald W. Lester wrote:
Upvar is used to implement pass-by-reference semantics.
...
I suspect Gerald is thinking of the traditional formal
definitions of call-by-reference and call-by-name.

Yes, after googling for "call-by-name" and then reading
a wikipedia article I now know what he referred to and I
accuse him of nitpicking, despite clearly understanding :-)

I agree. What most languages consider pass by reference is when the
reference refers to some value directly, rather than a key in a hash
table that can be used to get at the value. I don't recall how its
internals work, but I suppose upvar points the new variable name at
the old value, so I guess you could argue for that. However, in
practical terms, what you are passing to the proc that utilizes upvar
is the name - the key in the hash table, not the value - so I would
say that 'pass by name' is in some way a more accurate description.

.