|
|
|
|
|
by INTPnerd
2294 days ago
|
|
Which languages would you say are really good for defining your own types? Would they be a good fit for the example I provided where a function needs to accept integers larger than zero? Do they also allow you to define your own operations on those types? That is the part where classes seem to be a good fit, methods are basically operations supported by a type. |
|
I'm not an Ada expert, but it has excellent support for range-restricted integer types.[0]
Ada's 'discriminated types' are also fun. They let you create members which only exist when they're applicable. [1]
> Do they also allow you to define your own operations on those types
Looks like Ada supports operator overloading, yes. [2]
[0] https://www.adaic.org/resources/add_content/standards/05rm/h...
[1] https://www.adaic.org/resources/add_content/standards/05rat/...
[2] https://www.adaic.org/resources/add_content/standards/05aarm...