cast
Name | Type | Description | Optional |
---|---|---|---|
input |
?0 |
a value of type ?0 |
no |
Name | Type | Description | Optional |
---|---|---|---|
output |
?1 |
the result of casting the input value to type ?1 |
no |
cast
reads its input, and outputs the value <T>( x )
, where x
is the input value and T
is the output type (?1 above).
A large variety of type casts are supported in Transparency.
Any of the numeric or string types can be cast to any of the other numeric or string types.
String and symbol can be freely cast to one another. The conversion from symbol to string is effectively a nop, because a symbol is nothing but a memoized string.
Every type can be cast to bool
, and the result is false
if the value is the default value for its type, and true
otherwise. For example, in the case of a vector input type cast to bool, the vector of length 0 is the default value for all vector types, and casting it to` bool` gives false. All other vectors give `true
when cast to bool
.
The value nil
can be cast to any object type, and any object type can be cast to the type []
, i.e., an empty signature.
For all other casts, consult the Transparency manual.