
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday, March 15, 2003, at 12:35 AM, python-dev-request@python.org wrote:
I have thought about this as well; I think that the problem is that in C++, you have to declare "const" *everywhere* -- you can't just pass a mutable data structure and have the "right thing" happen the way it most obviously should. Arguably when one is mucking about at such a low level as is common in C++, this is something that you have to be really careful about, but I still think that it's handled badly in the syntax. Imagine for a moment that dictionaries and lists in Python had a "const" method which would immutabilify them (if that's even a word). The following example:
As opposed to:
I think that the latter is far less likely to annoy. Of course, in this hypothetical example, I can design all kinds of convenient behavior for these Python mutability operations to have, like 'copy' always returning a mutable shallow copy of the data structure in question, and '.const()' making an object immutable and then returning 'self'... This smells like another unformed PEP I don't have the time to think about or implement :-(, but I would definitely like to see mutability guarantees worm their way into the language at some point, too. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Darwin) iD8DBQE+c/tWvVGR4uSOE2wRAmeoAJ9tSOYOKTCxcl6Aj6reelmFU8OafwCggcNY smKTK1+HRCCEC9Pl/mhE4cI= =cMYA -----END PGP SIGNATURE-----
participants (1)
-
Glyph Lefkowitz