4 ms·
They aren't equivalent, they're in different domains and abstraction levels. Subtypes are an abstract notion in type theory and grammar while coercions are impl
by 3np 2y ago
They aren't equivalent, they're in different domains and abstraction levels. Subtypes are an abstract notion in type theory and grammar while coercions are implementation details/syntax.
> What if your implicit coercions aren't transitive
Have an example in mind?
- kragen 2y agoI think implicit coercions are a semantics issue, not an issue of implementation details. An example of intransitive implicit coercions: perhaps you have designed a language such that there is an implicit coercion from Booleans to integers (perhaps producing either 0 or 1), and also an implicit coercion from nullable references to Booleans. Arguably you have already sinned, but the situation becomes far worse if you apply transitive closure to the implicit coercions, because now a nullable reference to the integer 53 can be implicitly coerced to an integer—but the integer is 1, not 53!
- 3np 2y ago> I think implicit coercions are a semantics issue, not an issue of implementation details. Why not both? > An example of intransitive implicit coercions... Ok? Arbitrary nullable references are obviously not a subtype of booleans no matter what you do. If anything may break by substituting one type for another, those types do not have that subtype relationship, by definition.
- kragen 2y agoIt seems like you aren't thinking very clearly.