[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
215/376: Add ‘seq’ primop
From: |
Ludovic Courtès |
Subject: |
215/376: Add ‘seq’ primop |
Date: |
Wed, 28 Jan 2015 22:05:09 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit a54c263402cf140b6f91e26c02f13cbeeda76583
Author: Eelco Dolstra <address@hidden>
Date: Mon Sep 22 14:53:21 2014 +0200
Add ‘seq’ primop
---
src/libexpr/primops.cc | 12 ++++++++++++
tests/lang/eval-fail-seq.nix | 1 +
tests/lang/eval-okay-seq.exp | 1 +
tests/lang/eval-okay-seq.nix | 1 +
4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index c721a56..2da15b3 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);
diff --git a/tests/lang/eval-fail-seq.nix b/tests/lang/eval-fail-seq.nix
new file mode 100644
index 0000000..cddbbfd
--- /dev/null
+++ b/tests/lang/eval-fail-seq.nix
@@ -0,0 +1 @@
+builtins.seq (abort "foo") 2
diff --git a/tests/lang/eval-okay-seq.exp b/tests/lang/eval-okay-seq.exp
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/tests/lang/eval-okay-seq.exp
@@ -0,0 +1 @@
+2
diff --git a/tests/lang/eval-okay-seq.nix b/tests/lang/eval-okay-seq.nix
new file mode 100644
index 0000000..0a9a21c
--- /dev/null
+++ b/tests/lang/eval-okay-seq.nix
@@ -0,0 +1 @@
+builtins.seq 1 2
- 206/376: Store.so: Add dependency on libnixutil, (continued)
- 206/376: Store.so: Add dependency on libnixutil, Ludovic Courtès, 2015/01/28
- 200/376: Add some instrumentation for debugging GC leaks, Ludovic Courtès, 2015/01/28
- 210/376: Inline Bindings::find(), Ludovic Courtès, 2015/01/28
- 202/376: On Linux, disable address space randomization, Ludovic Courtès, 2015/01/28
- 205/376: Update spec file, Ludovic Courtès, 2015/01/28
- 201/376: Add Make flag to disable optimization, Ludovic Courtès, 2015/01/28
- 213/376: configure: Force regeneration of Makefile.config, Ludovic Courtès, 2015/01/28
- 212/376: attrNames: Don't allocate duplicates of the symbols, Ludovic Courtès, 2015/01/28
- 216/376: Handle cycles when printing a value, Ludovic Courtès, 2015/01/28
- 211/376: Fix off-by-one, Ludovic Courtès, 2015/01/28
- 215/376: Add ‘seq’ primop,
Ludovic Courtès <=
- 209/376: Store Attrs inside Bindings, Ludovic Courtès, 2015/01/28
- 208/376: Remove bogus comment, Ludovic Courtès, 2015/01/28
- 219/376: Add ‘deepSeq’ primop, Ludovic Courtès, 2015/01/28
- 225/376: Pass through --set from nix-install-package command line to nix-env, Ludovic Courtès, 2015/01/28
- 214/376: Add a function ‘valueSize’, Ludovic Courtès, 2015/01/28
- 145/376: Use proper quotes everywhere, Ludovic Courtès, 2015/01/28
- 226/376: Add --force-name support for --set in nix-env, to support nix-install-package --set, Ludovic Courtès, 2015/01/28
- 220/376: Don't evaluate inside a "throw", Ludovic Courtès, 2015/01/28
- 217/376: Rename strictForceValue -> forceValueDeep, Ludovic Courtès, 2015/01/28
- 227/376: Updated documentation for nix-install-package to mention --set flag, Ludovic Courtès, 2015/01/28