From 3d14ed92702bf58123405f406f82be083a28b959 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Oct 2007 14:06:43 +0000 Subject: [PATCH] * A primop for calling functions strictly (i.e. forcing evaluation of argument). Necessary to actually get memoisation of functions like "fib" with maximal laziness. --- src/libexpr/primops.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 3d080dec3..129b9e2e5 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -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 *************************************************************/ @@ -993,6 +1004,9 @@ void EvalState::addPrimOps() addPrimOp("toString", 1, prim_toString); addPrimOp("__substring", 3, prim_substring); addPrimOp("__stringLength", 1, prim_stringLength); + + // Strictness + addPrimOp("strict", 2, prim_strict); }