What is a type error?
Andreas Rossberg
rossberg at ps.uni-sb.de
Fri Jul 14 05:10:53 EDT 2006
Darren New wrote:
> Andreas Rossberg wrote:
>
>> Yes, technically you are right. But this makes a pretty weak notion of
>> mutability. All stateful data structures had to stay within their
>> lexical scope, and could never be passed to a function.
>
> Not really. The way Hermes handles this is with destructive assignment.
> Each variable holds a value, and you (almost) cannot have multiple
> variables referring to the same value.
OK, this is interesting. I don't know Hermes, is this sort of like a
dynamically checked equivalent of linear or uniqueness typing?
> If you want to assign Y to X, you use
> X := Y
> after which Y is considered to be uninitialized. If you want X and Y to
> have the same value, you use
> X := copy of Y
> after which X and Y have the same value but are otherwise unrelated, and
> changes to one don't affect the other.
Mh, but if I understand correctly, this seems to require performing a
deep copy - which is well-known to be problematic, and particularly
breaks all kinds of abstractions. Not to mention the issue with
uninitialized variables that I would expect occuring all over the place.
So unless I'm misunderstanding something, this feels like trading one
evil for an even greater one.
- Andreas
More information about the Python-list
mailing list