|
|
|
|
|
by zarakshR
446 days ago
|
|
> because PHP and Javascript will implicitly convert back and forth If you can provide (valid!) methods `T -> U` and `U -> T` for two types, why wouldn't `T = U` hold? (Atleast for types where `=` makes sense) This is the definition I am using: > S is a subtype of T, written S <: T, if a value of type S can safely be used in any context where a value of type T is expected. from Pierce's "Software Foundations" Of course, you may not want to make `String <: Number` and `Number <: String` (and thus `String = Number`), because there is no sensible way to do so; but this is an issue with the way PHP/JS handles subtyping, not with the notion of subtyping itself and certainly does not apply to the example of nullable types. Unfortunately, I am not familiar enough with C++ to comment on the other question, sorry! |
|