3 ms·
Assignment is essentially similar to subtyping, if one says: A := B Then all values that could be bound to B could be bound to A also (so B <= A), but if the
by seanmcdirmid 13y ago
Assignment is essentially similar to subtyping, if one says:
A := B
Then all values that could be bound to B could be bound to A also (so B <= A), but
if the other way was also taken (B = A), then
A := C
Would imply that B = C, which leads to all sorts of safety problems...so you don't do that. At the end of the day, to make HM work with assignment, you need something like ML's "value restriction" that prevents full unification between A and B.
- gsg 13y agoNitpick: it's generalisation that is prevented by the value restriction. Unification works just fine: let test r = r := `A; r := `B; r := `C r gets unified with all of `A, `B and `C: no problem.