<< Prev | - Up - | Next >> |
The types of values can be checked in Oz dynamically, as illustrated by the following examples.
{Inspect {IsRecord R}}
{Inspect {IsRecord F}}
{Inspect {Or {IsRecord ~100}
{IsBool ~100}}}
{Inspect {And {And
{IsNumber ~100}
{IsInt ~100}}
{IsFloat ~100}}}
{Inspect {Not {IsRecord false}}}
{Inspect {IsRecord {IsRecord false}}}
{Inspect {And
{And
{IsList L}
{IsTuple L}}
{IsRecord L}}}
It might be surprising that the Unit, the Booleans, and atoms are records. The reason is that a record need not to have subrecords.
There also exists a predefined procedure in Oz which computes the type of a given value. This is the procedure Value.status
. When applied, it return not only the type of its input argument but also its actual status which may be either determined, kinded, or free.
{Inspect [{Value.status R}
{Value.status T}
{Value.status L}
{Value.status F}]}
For functional programming, we'd better deal only with values of status `determined', in order to avoid suspensions (blocking computations).
<< Prev | - Up - | Next >> |