Re: IsString



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
> >
>
.



Relevant Pages

  • Indentation and optional delimiters
    ... This is the best praise of semantic indentation I have read so far, ... students learn Python basics compared to other languages, ... probable such languages will change, ... the widespread reference semantics in Python is one of the things ...
    (comp.lang.python)
  • Re: IsString
    ... > with pass-by-reference. ... Python has the semantics normally associated ... mutable object that refers to the immutable object. ...
    (comp.lang.python)
  • Re: Python is Considered Harmful
    ... But Python isn't a functional ... that's true but functional programmers come from a "carry your semantics ... It sets up an iteration variable and then mutates the iteration variable for ... Nothing surprising here for someone who studies language semantics. ...
    (comp.lang.python)
  • Re: Python is Considered Harmful
    ... But Python isn't a functional ... that's true but functional programmers come from a "carry your semantics ... It sets up an iteration variable and then mutates the iteration variable for ... Nothing surprising here for someone who studies language semantics. ...
    (comp.lang.lisp)
  • Re: IsString
    ... If your language is confused or misleading, your understanding ... | with pass-by-reference. ... Python has the semantics normally associated ...
    (comp.lang.python)