Does Python need "const" ? (Re: PEP 218 Re: ANN: set-0.1 mod ule available)

Gustavo Cordova gcordova at hebmex.com
Mon May 20 09:31:09 EDT 2002


> [Huaiyu Zhu]
> > # const reference to mutable object
> > const a = "abc"
> > #   forbids a = "xyz"
> > #   allows b = a; a += "uvw"; which would set b to "abcuvw".
> 
> Presumably, you mean:
> 
> > #   allows b = a; b += "uvw"; which would set b to "abcuvw".
> 

This seems quite contradictory:

You intend "const" to forbid such things as "a = 'xyz'" once
it's been binded to "a = 'abc'". But, you say it must permit
"a += 'xyz'" so that a will end up as 'abcxyz'.

But, strings are immutable objects, so a += operation will
effectively bind "a" to an diffrent object, an operation
more like:

	a = "abc" + "xyz"

How do you plan to attack the immutable object "problem"?

-gustavo





More information about the Python-list mailing list