On 13/10/2017 15:59, Julien Salort wrote:
Le 12/10/2017 à 17:57, bartc a écrit :

With a const struct, you are stopped from directly modifying elements, but if an element is a pointer, nothing stops you writing to what the pointer points to, unless that has a const target too. And then you've going to have problems doing normal updates. This constness just insinuates itself everywhere.

That is not very different from the mutable/immutable concept in Python, is it ? A tuple is immutable, but if it contains a mutable object, nothing prevents you from mutating it.
Does it mean you think the mutable/immutable concept of Python is flawed?

When you put it like that, then yes!

But it depends on how you define the value of a tuple. If that is a recursive definition that includes all nested object levels, then it would be harder to keep the whole thing constant.

If you look only one level deep, then it can be fully immutable (never mind that some elements could be functions that will give a different result each time they are evaluated).


--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to