Casting is a way to change some value from a type to another one.
Pliant casting machinery is a fairly sophisticated one since several casting functions can transparently be involved to get the result if no direct one is available. In the end, it is just powerful enough for built in numerical data types to have no special handling.
var Int i
var Int i
Defining casting functions
function 'cast Int' f -> i
If no attribut is provided, 'explicit' will be assumed. See bellow.
function 'cast uInt16_li' i -> ii
An 'implicit' casting function shall be used to provide implit casting.
function cast_Int_Float i -> f
'extension' is the same as 'implicit', but it futhermore specify that the target data type is a superset of the source one. In this example, 'Float' is considered as a superset of 'Int'.
function 'cast Float32' f -> f32
'reduction' means that the source data type is a subset of the target one. In this sample, 'Float' is considered as a superset of 'Float32'.
var Float f
function 'cast Status' f -> s
An 'explicit' casting function can be used only in an ... explicit casting.