passing by refference
Fredrik Lundh
fredrik at pythonware.com
Thu May 15 17:39:30 EDT 2003
Doug Quale wrote:
> According to Joshua, me and R5RS. R5RS says
>
> "When the procedure is later called with some actual
> arguments, the environment in which the lambda expression was evaluated will
> be extended by binding the variables in the formal argument list to
> fresh locations, the corresponding actual argument values will be stored
> in those locations, and the expressions in the body of the lambda expression
> will be evaluated sequentially in the extended environment."
>
> That's call-by-value by definition.
but that's not how Python works.
in Python, the variables in the formal argument list are bound to the
actual argument objects. the objects are _shared_ between caller
and callee; there are no "fresh locations" or extra "stores" involved.
(which, of course, is why the CLU folks called this mechanism "call-
by-sharing". and they were real computer scientists, working for a
real computer science laboratory ;-)
and btw, Python functions doesn't run in an extended environment,
either. function bodies have very limited access to the surrounding
environment. but that's another story.
</F>
More information about the Python-list
mailing list