Conversation
so that we see all error messages, and not just the first.
previously, objects might have had a class identity that is not valid across different actors, so we distinguished between shared and non-shared objects. With `is` removed (#145), we no longer that distinction; an object is a subtype of `Shared` if and only if all fields are (same as for tuples, as one would expect). This removes a bunch of code. It might be that Andreas could have implemented this faster on his own than reviewing this PR, but I wanted to sieze the opportunity to learn more about the type chekcker etc. It is one of the clean-ups menionted in #81 (there are more left though). It fixes #103.
|
An object is just a record of closures. There are no mutable classes, just mutable fields. An object with a public mutable field ought to be non-sharable (and I think this PR does not check that, thanks!). An object with private mutable field, well, that field isn’t really part of the object. It is merely in the closure of the functions in the public fields. And then the question is just if these functions are sharable. |
Actually, objects with mutable fields are correctly recognized as non-shared. All is well. |
|
Yes, this is problematic, because it would imply which doesn't make sense. It looks like your change currently rejects that, but that breaks transitivity of subtyping, so is not viable -- and I can still do Things will become more fishy with generics: This would type-check, but what would it send? |
|
What he said. A halfway house might be to disallow forgetting of mutable fields via subtyping, but that's a bit gross..., |
|
Ouch, ok. So I guess objects are more than just tuples with named fields after all :-( OTOH, if I drop a non-sharable field from an object, the remaining object is sharable. This is not specific to mutable fields: We’d have the same problem if larger tuples were subtypes of smaller ones (which ought to be a relatively benign feature, ought it not?) Maybe the problem is that we try hard ot use subtyping to characterize sharable types, when the proposition “is sharable” simply is not a downward closed set in the partial order of subtypes? |
|
Correct, this applies to all non-sharable types of fields.
I don't think it makes a difference. If you were to use something else, say, type class constraints, you'd still have the same kind of problem as long as subtyping exists at all: Though here, perhaps, you could argue that a coercive interpretation of subtyping would explain this away. |
|
I don’t see the problem with your example. Clearly
It seems it does make a difference: If we don’t expect that “can be shared“ is a downset, then we no longer expect “ and the problem goes away. Is “is sharable” an upward-closed predicate? I.e. for every So maybe all problems go away as soon as soon as make |
|
Under subtyping, T includes all values whose most specific type is a subtype of T, so "T is sharable", no matter how expressed, always extends to all subtype values. Unless you use a coercive interpretation of subtyping, which might get tricky in higher-order cases. |
|
Hmm, I see what you are saying: The value So “ |
|
I agree this is unfortunate. I wish there was a nicer solution, but I can't think of one. |
previously, objects might have had a class identity that is not valid
across different actors, so we distinguished between shared and
non-shared objects. With
isremoved (#145), we no longer thatdistinction; an object is a subtype of
Sharedif and only if allfields are (same as for tuples, as one would expect).
This removes a bunch of code. It might be that Andreas could have
implemented this faster on his own than reviewing this PR, but I wanted
to sieze the opportunity to learn more about the type chekcker etc.
It is one of the clean-ups menionted in #81 (there are more left though).
It fixes #103.