4 ms·
Maybe I'm off the mark here, but in my mind the definition of subtype is as follows: t1 is a subtype of t2 if any instance of t1 is an instance of t2. Surely wi
by wesselbindt 2y ago
Maybe I'm off the mark here, but in my mind the definition of subtype is as follows: t1 is a subtype of t2 if any instance of t1 is an instance of t2. Surely with this definition String is a subtype of String?. Every instance of String (i.e. every string) is an instance of String?, after all.
Post-submit clarity edit: Ah, I think I understand. You're objecting to OP's definition of subtyping, as it breaks down for certain language implementations.
- seanmcdirmid 2y agoString <: String? is true (Any non-null string is a possibly null string), but String? <: String isn’t true (Any possibly null string may not be a non-null string).
- wesselbindt 2y agoWe're all in agreement there it seems.
- seanmcdirmid 2y agoIf you just state it as a logical quantified proposition, it’s pretty obvious unless the type is complicated (then you need to break it down into multiple logical quantified propositions).
- wesselbindt 2y agoYes of course, but again, I don't think anyone disagrees with you on this.