I was fiddling around with things (just probing what works and what doesn’t) and discovered that real numbers seem to be treated as a kind of number for the purpose of covariance / contravariance of composite types. However, it doesn’t appear to actually work as one would expect. Is this a bug? More specifically, which is the bug – the fact that they’re treated as convertible, or the fact that they don’t actually convert when used as such?
Code:
To decide what number is the best integer (this is integer decision): decide on 5.
To decide what real number is the best real number (this is real decision): decide on 5.2.
fun stuff is a phrase nothing -> real number that varies. fun stuff is integer decision.
When play begins, say "fun stuff: [fun stuff applied][line break]".
I would have expected one of two outcomes from this:
- It fails to compile, because a number and real number are not compatible.
- It outputs the text “fun stuff: 5” or maybe “fun stuff: 5.0”.
But instead, it outputs the text “fun stuff: 7.0065 × 10^-45”.
I’m not sure if other composite types such as lists or relations can be coaxed into a similar outcome. It also doesn’t seem to work for phrase parameter types – I can’t assign a phrase taking a real number to a variable whose type is a phrase taking a number.