From a54c263402cf140b6f91e26c02f13cbeeda76583 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 22 Sep 2014 14:53:21 +0200 Subject: =?UTF-8?q?Add=20=E2=80=98seq=E2=80=99=20primop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libexpr/primops.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/libexpr') diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index c721a5681..2da15b3c5 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -383,6 +383,15 @@ static void prim_getEnv(EvalState & state, const Pos & pos, Value * * args, Valu } +/* Evaluate the first argument, then return the second argument. */ +void prim_seq(EvalState & state, const Pos & pos, Value * * args, Value & v) +{ + state.forceValue(*args[0]); + state.forceValue(*args[1]); + v = *args[1]; +} + + /* Evaluate the first expression and print it on standard error. Then return the second expression. Useful for debugging. */ static void prim_trace(EvalState & state, const Pos & pos, Value * * args, Value & v) @@ -1424,6 +1433,9 @@ void EvalState::createBaseEnv() addPrimOp("__tryEval", 1, prim_tryEval); addPrimOp("__getEnv", 1, prim_getEnv); + // Strictness + addPrimOp("__seq", 2, prim_seq); + // Debugging addPrimOp("__trace", 2, prim_trace); addPrimOp("__gcCanary", 1, prim_gcCanary); -- cgit v1.2.3