passing by refference
Joshua Marshall
joshway_without_spam at myway.com
Thu May 15 13:13:33 EDT 2003
Fredrik Lundh <fredrik at pythonware.com> wrote:
...
> did you read reference 1?
> http://www.cs.berkeley.edu/~jcondit/pl-prelim/liskov77clu.pdf
<snip>
> replace "CLU" with "Python", "record" with "instance", and "procedure"
> with "function or method", and you get a pretty accurate description
> of Python's object model.
> if you don't agree, please tell us what Python does differently. be very
> specific.
Yes, I agree this is an accurate description of Python. CLU function
invocation seems to have call-by-value semantics as well (by my
definition and, I believe, the standard definition). And like python,
values are object references.
>From "A History of CLU":
In fact, CLU procedures do not share variables at all. In addition
to there being no free variables, there is no call-by-reference.
Instead arguments are passed "by object"; the (pointer to the) object
resulting from evaluating the actual argument expression is assigned
to the formal. (Thus passing a parameter is just doing an assignment
to the formal.)
This exactly describes call-by-values, where the values are object
references. A few lines further down:
A CLU procedure can have side effects only if the argument objects
can be modified (since it cannot access the caller's variables).
That is the objects /themselves/, not the l-values holding references
to them. I don't think we disagree about semantics, only terminology.
I don't think we'll make further progress here.
More information about the Python-list
mailing list