The types
The language reference gives the form and the rules of each one.
A value keeps its type
RSL has zero implicit conversions. This calculation adds aBool to a number:
convert/rater.rsl
convert/rater.rsl
convert/rater.rsl
if self.c then 1 else 0.
A type carries facts
A numeric input states its precision and its range:where clause is a refinement: it narrows the type to the values that pass it.
A request with a value outside the range is refused before any calculation runs.
From the facts of the inputs, the check works out the facts of each calculation.
This one declares a range of 0 to 5 for the sum of two inputs:
range/rater.rsl
range/rater.rsl
range/rater.rsl
A condition narrows a type
Inside a branch, the check knows what the condition says. Here the divisor has the range -9 to 9, and the guard removes 0 from it:narrow/rater.rsl
narrow/rater.rsl
narrow/rater.rsl
match narrows in the same way: the arm Some(v) => reads a present value, and each arm of an enumeration reads one member.
Absence is a type
RSL is free of null. A value that can be absent has the typeOption(T), and a calculation reads it with a match on both cases.
A read that skips a case gets E-OPTION-MATCH.
A follow-up input is asked only under a condition.
A calculation reads it under that condition, so an unasked question stays distinct from an answer of false.
Lists and maps
A plainList(Record) keeps the order of the request.
A list declared keyed by is a map from key to record: its order is free to change, and a selection breaks a tie by the key.
Lists and keys gives the rules.
What the type system leaves out
- Generic types and user-defined functions. The functions are a fixed list, in the function reference.
- Arithmetic on units.
Premium,Rate,FactorandPctstate the role of a number, and each is an exact rational. This sum of a premium and a factor compiles:
units/rater.rsl
units/rater.rsl
units/rater.rsl
Premium whose expression holds only factors.
Related
- Language guarantees states what a passing check means.
- Exact numbers explains precision and rounding.
- Missing answers explains optional values and follow-up inputs in a request.