Is 'everything' a refrence or isn't it?

Mike Meyer mwm at mired.org
Sat Jan 7 15:19:42 EST 2006


"Fredrik Lundh" <fredrik at pythonware.com> writes:
> In ordinary CS, "call by reference" generally means that the function is
> handed a reference to the *variable* holding the *value*.

That's the strictest definition of "call-by-reference". It's got a
major problem in that it means doing (with C syntax) "foo(&l[23])"
isn't CBR, because I didn't pass a reference to a *variable*. For
Python to be CBR, you have to use a broad definition of CBR

> Saying that Python uses "call by value" is probably more correct (where
> the values are references), but that's even more confusing.

I wouldn't say 'more correct', because of the above. But since *all*
paramater passing mechanisms pass a value of some kind - even
call-by-substitution - they're all call by value with that
definition. That makes the phrase pretty much useless.

The problem is that CBR and CBV were defined for langauges with
variables that had addresses, and assignments that copied values into
those addresses. The definitions were stretched by various groups to
fit their language, and some of the definitions disagree about edge
cases. The calling mechanisms of languages that have variables that
are bound to objects are all edge cases.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list