anything like C++ references?
Martin v. Löwis
martin at v.loewis.de
Tue Jul 15 00:56:56 EDT 2003
Stephen Horne <intentionally at blank.co.uk> writes:
> Write...
>
> x = classname()
> y = x
>
> ... and that would be an error.
[...]
> However...
>
> x = &classname()
> y = x
>
> ... and everything is fine.
If any kind of implicit reference assignment would be an error, then I
assume
x = classname()
x.foo()
would also be an error? because that assigns a reference of the object
to the implicit 'self' parameter of the method?
> > This is completely different from the notion of
> >values in C or C++, where each occurrence of the literal 5 creates a
> >new value whose state is 5.
>
> Not true. Each occurence of the literal 5 creates a new 'symbol' which
> represents the value 5. The immutability of values is preserved in
> C++.
That is not true. There are no "symbols" in C beyond those that you
use to name functions and global variables. Every occurrence of an
integer literal *does* create a temporary object, every time the
literal is *executed*.
Regards,
Martin
More information about the Python-list
mailing list