[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
18/20: gexp: Add 'sexp->gexp'.
From: |
guix-commits |
Subject: |
18/20: gexp: Add 'sexp->gexp'. |
Date: |
Mon, 1 Mar 2021 09:32:12 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 74af8db7a0341291449122f9593d245d23948a78
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Feb 28 21:29:53 2021 +0100
gexp: Add 'sexp->gexp'.
* guix/gexp.scm (sexp->gexp): New procedure.
* tests/gexp.scm ("sexp->gexp"): New test.
---
guix/gexp.scm | 11 +++++++++++
tests/gexp.scm | 7 +++++++
2 files changed, 18 insertions(+)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 5a140ee..efa8e57 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -39,6 +39,7 @@
#:use-module (ice-9 match)
#:export (gexp
gexp?
+ sexp->gexp
with-imported-modules
with-extensions
let-system
@@ -1843,6 +1844,16 @@ of name/gexp-input tuples, and OUTPUTS, a list of
strings."
(ungexp body))))
+(define (sexp->gexp sexp)
+ "Turn SEXP into a gexp without any references.
+
+Using this is a way for the caller to tell that SEXP doesn't need to be
+scanned for file-like objects, thereby reducing processing costs. This is
+particularly useful if SEXP is a long list or a deep tree."
+ (make-gexp '() '() '()
+ (lambda () sexp)
+ (source-properties sexp)))
+
(define* (gexp->script name exp
#:key (guile (default-guile))
(module-path %load-path)
diff --git a/tests/gexp.scm b/tests/gexp.scm
index a30d0ff..f73ca94 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -96,6 +96,13 @@
(null? (gexp-inputs exp))
(gexp->sexp* exp))))
+(test-equal "sexp->gexp"
+ '(a b (c d) e)
+ (let ((exp (sexp->gexp '(a b (c d) e))))
+ (and (gexp? exp)
+ (null? (gexp-inputs exp))
+ (gexp->sexp* exp))))
+
(test-equal "unquote"
'(display `(foo ,(+ 2 3)))
(let ((exp (gexp (display `(foo ,(+ 2 3))))))
- 05/20: gexp: Micro-optimize sexp serialization., (continued)
- 05/20: gexp: Micro-optimize sexp serialization., guix-commits, 2021/03/01
- 04/20: packages: Core procedures are written in monadic style., guix-commits, 2021/03/01
- 01/20: build-system: Rewrite using gexps., guix-commits, 2021/03/01
- 07/20: gexp: 'gexp-inputs' returns both native and non-native inputs., guix-commits, 2021/03/01
- 03/20: packages: Simplify patch instantiation., guix-commits, 2021/03/01
- 09/20: gexp: Micro-optimize 'gexp->sexp' and 'lower-inputs'., guix-commits, 2021/03/01
- 12/20: grafts: Inline 'grafting?' and 'set-grafting'., guix-commits, 2021/03/01
- 15/20: serialization: Micro-optimize string literal output in 'write-file-tree'., guix-commits, 2021/03/01
- 16/20: gexp: Optimize 'with-build-variables'., guix-commits, 2021/03/01
- 17/20: packages: Default origin 'patch-flags' is a gexp., guix-commits, 2021/03/01
- 18/20: gexp: Add 'sexp->gexp'.,
guix-commits <=
- 08/20: gexp: Keep 'lower-inputs' private., guix-commits, 2021/03/01
- 10/20: store: Object cache profiling shows the number of entries., guix-commits, 2021/03/01
- 11/20: gexp: Reduce allocations while traversing lists., guix-commits, 2021/03/01
- 06/20: gexp: 'gexp-inputs' returns a list of <gexp-input> records., guix-commits, 2021/03/01
- 13/20: store: Micro-optimize object cache lookup., guix-commits, 2021/03/01
- 14/20: gexp: Reduce allocations in 'gexp-attribute'., guix-commits, 2021/03/01
- 20/20: build-system: Use 'input-tuples->gexp' and 'outputs->gexp'., guix-commits, 2021/03/01
- 19/20: build-system: Use 'sexp->gexp' for plain sexps., guix-commits, 2021/03/01