{ 1 }
is type lazy number
Functions can require that their parameters be lazy with the ~
:
fn times n ~do = if (n <= 0) { nothing } { eval do; times (n - 1) do }
(the ;
meaning chain evaluation of two expressions)
If a lazy value is passed to a function that doesn't want a lazy value,
then the lazy value is automatically evaluated. This, as a consequence
means that the definition of the eval
function in the language can
be as simple as fn eval x = x
, since the parameter is x
not ~x
, any
lazy value that is passed to it is automatically evaluated.
Laziness is at most singly nested. It is automatically flattened, that is:
{ { 1 } }
is still type lazy number
, this is achieved by always strictly
evaluating the last (return) expression in a lazy block. Since the last expression
in { { 1 } }
is { 1 }
which is lazy number
. Conceptually this can be
thought of turning this expression into { eval { 1 } }
, but it can probably
be done implicitly when type-checking and evaluating a lazy block...