Binding Rules
Now that we have seen all available types, we will see the last section on the type system: the binding rules. These specify whether or not you can put a value of a given type inside a variable of another type. Most of these are pretty straightforward, but listing them makes things easier on complex cases.
A type A is bindable to type B if and only if one of the following cases apply:
Bis*.AandBare the same.- Both
AandBare constant references and their inner types are bindable. - Both
AandBare mutable references and their inner types are bindable. Ais a structural type and its alias is bindable toB.Bis a structural type andAis bindable to its alias.Ais a template andBfollows its constraints and the substitution is not incoherent with the rest.Bis a template andAfollows its constraints and the substitution is not incoherent with the rest.Ais a sum type and all its variants are bindable toBBis a sum type andAis bindable to any of its variants.- Both
AandBare product types with the same length and every typeA_iis bindable toB_i. - Both
AandBare the same parametric type with the same class and every type parameterA_iis bindable to the type parameterB_i. - Both
AandBare function types and both their argument types and return types are bindable.
As you can see, checking whether or not two types are bindable is a recursive process, but the ideas are very intuitive given the descriptions in their corresponding sections. Now that we have defined one of the key aspects of Ryna, we will begin explaining how to use the language.