4 ms·
> A type is a collection of possible values Ok, but do two collections with the same values always correspond to the same type?
by amelius 10y ago
> A type is a collection of possible values
Ok, but do two collections with the same values always correspond to the same type?
- kd0amg 10y agoIt depends on the language. If you have, for example, a type-and-effect system, a type can contain information (like "we wrote to stdout while computing this") that is never reflected in the value itself. In a formal setting, it's more appropriate to describe a type as a collection of pieces of source code, so that `2+3` and `print "computing...\n"; 2+3` have different types even though they'll evaluate to the same thing.
- paulddraper 10y agoYes, but if remember you can always say that the values are different. A blue 5, and a red 5. Five feet, or five inches.
- munificent 10y agoYes, they do.
- acjohnson55 10y agoGenerally, no, at least with nominal typing.