mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 12:41:00 +01:00
* A primop for calling functions strictly (i.e. forcing evaluation of
argument). Necessary to actually get memoisation of functions like "fib" with maximal laziness.
This commit is contained in:
parent
8e0488370d
commit
3d14ed9270
1 changed files with 14 additions and 0 deletions
|
|
@ -927,6 +927,17 @@ static Expr prim_stringLength(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************
|
||||||
|
* Strictness
|
||||||
|
*************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
static Expr prim_strict(EvalState & state, const ATermVector & args)
|
||||||
|
{
|
||||||
|
return evalExpr(state, makeCall(args[0], evalExpr(state, args[1])));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Primop registration
|
* Primop registration
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
|
|
@ -993,6 +1004,9 @@ void EvalState::addPrimOps()
|
||||||
addPrimOp("toString", 1, prim_toString);
|
addPrimOp("toString", 1, prim_toString);
|
||||||
addPrimOp("__substring", 3, prim_substring);
|
addPrimOp("__substring", 3, prim_substring);
|
||||||
addPrimOp("__stringLength", 1, prim_stringLength);
|
addPrimOp("__stringLength", 1, prim_stringLength);
|
||||||
|
|
||||||
|
// Strictness
|
||||||
|
addPrimOp("strict", 2, prim_strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue