IsString

Chris Mellon arkanes at gmail.com
Thu Dec 15 19:50:02 EST 2005


On 12/15/05, Chris Mellon <arkanes at gmail.com> wrote:
> <snip a bunch of stuff>
> > Terminology is important, because we understand the world through
> > language. If your language is confused or misleading, your understanding
> > will also be confused or incomplete.
>
> I think the issue is pretty simple, myself:
>
> With mutable objects, Python has the semantics normally associated
> with pass-by-reference.
>
> With immutable objects, Python has the semantics normally associated
> with pass-by-value.


Meant to include this in first post:

This is all you have to know to use Python, even very advanced Python.
Everything after this point is basically comp-sci trivia and argument
about definitions.

>
> So you could say that Python has both pass-by reference and
> pass-by-value (modulo the fact that pass-by-reference doesn't exist at
> some level, and is a semantic layer on top of pass-by-value. But
> semantics are what we're talking about here).
>
> However, there is *no way* in Python to get pass-by-value semantics
> with a mutable object, or pass-by-reference semantics with an
> immutable one (you can build your own scaffolding to mimic it, but the
> language won't change it's semantics for you).
>
> Therefore, it's more correct to say that Python has neither
> pass-by-reference semantics or pass-by-value semantics, but some third
> thing. And thus the name pass-by-object, where the calling semantics
> are that you always get a reference to an object, but what (if any)
> other names are bound to that object, or if they can be bound to that
> object, depends on the object.
>
> When you can pass a mutable int to a function (not pass a
> namespace/name pair, but a real live mutable int), then Python will
> have pass-by-reference.
>
> When you can pass a list that isn't a shared reference without
> explicitly copying it or subclassing it to be immutable, then Python
> will have pass-by-value.
>
> In the meantime, it has pass-by-object.
>
> >
> >
> >
> > --
> > Steven.
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>



More information about the Python-list mailing list