- #1
elcaro
- 128
- 28
- TL;DR Summary
- Type systems in most programming languages are not very specific about the kind of values the type defines and miss the mathematical operations defined by mathematical set theory, like UNION, INTERSECTTION, MINUS. Is there a programming language which does have a type system that more or less conforms to mathematical set theory?
A type in a programming language more or less specifies what values are allowed for a given type. A type has some similarities with a set, but most programming languages lack the operations which a set has. For example, in C one can define a new type based on two other types as a union of those types with the union keyword, but there is no simple way to create a type based on the minus or interesction of two other types.
For languages like C++, one could define a class for such cases and define methods for defining such operations.
For languages like C++, one could define a class for such cases and define methods for defining such operations.