Re: IsString
- From: Chris Mellon <arkanes@xxxxxxxxx>
- Date: Thu, 15 Dec 2005 18:50:02 -0600
On 12/15/05, Chris Mellon <arkanes@xxxxxxxxx> 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
> >
>
.
- References:
- IsString
- From: Tuvas
- Re: IsString
- From: Donn Cave
- Re: IsString
- From: Fredrik Lundh
- Re: IsString
- From: Tuvas
- Re: IsString
- From: Steven D'Aprano
- IsString
- Prev by Date: Re: ActivePython and Amara
- Next by Date: RE: IsString
- Previous by thread: Re: IsString
- Next by thread: Re: IsString
- Index(es):
Relevant Pages
|