4 ms·
> For a static type system it makes more sense to think of a type as a set of supported operations rather than a set of values. It really doesn't. 'any', 'unk
by louthy 5y ago
> For a static type system it makes more sense to think of a type as a set of supported operations rather than a set of values.
It really doesn't. 'any', 'unknown', 'object', and 'dynamic' are all 'top' in type systems (the type that is the super-type of all other types), they hold the set of all values. The fact a language assigns additional semantics based on their name is just sugar over the underlying type system, the type-system can live quite happily without names.
But even then, you could consider the name of a type a 'discriminating tag', like in discriminated unions. So, something like:
type Top = Any a
| Unknown a
| Object a
| Dynamic a
The same type, but with different states depending on the semantics of the language.
- goto11 5y agoI don't know what you mean with "sugar", but the fact that several different types can represent the exact same set of possible values means that a type cannot be considered as just a set of possible values. > The same type, but with different states depending on the semantics of the language. This is just playing games with definitions. What you call "state" is a type in the type system of the programming language.