-
Notifications
You must be signed in to change notification settings - Fork 31
Discussions on the type system
Sometimes it is not immediately clear whether we should allow or disallow a kind of expression. Such cases are discussed here. Feedback is very welcome.
Should these cases be allowed or disallowed?
-
1 < 2
=> allowed (standard use) -
[1, 2, 3] < 4
=> disallowed (useall
orany
) -
[1, 2, 3] < [4, 5]
=> disallowed (makes no sense) -
[1, 2, 3] < [4, 5, 6]
=> disallowed (in principle we could compare them pairwise, but as far as we know, there is no use case for that. Furthermore, allowing this would prove difficult for expressions that return a list with undetermined length, e.g., comparing a list with constraint (1..3) with another with constraint (3..5)) -
1 all < 2
=> disallowed (the cardinality operatorall
is redundant) -
[1, 2, 3] all < 2
=> allowed (standard use) -
2 all > [1, 2, 3]
=> disallowed (see section Operators withall
andany
)
Should values of all of these types be comparable with =
and <
? => yes (same rules as discussed for numbers in previous section apply)
Should they be allowed to be mixed (e.g., comparing a date
with a zonedDateTime
, or a date
with a time
)? => no (there is no good way to compare them; users should explicitly convert between them, e.g., by adding a time zone to a date
object)
When using the prefixes all
and any
with operators such as =
, <>
and >=
, one of the arguments should be a single value. In principle, this could be either the left or the right operand, but I think it is better to have a consistent position for the single item, i.e., by always forcing the right operand to be singular. E.g.,
- this is allowed:
[1, 2, 3] all < 2
- this is disallowed:
2 all > [1, 2, 3]
Furthermore, we disallow using these prefixes unnecessarily, such as in 5 any = 3
and 2 all <= 10
.