[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/22: gexp: Add 'sexp->gexp'.
From: |
guix-commits |
Subject: |
08/22: gexp: Add 'sexp->gexp'. |
Date: |
Tue, 30 Mar 2021 17:00:15 -0400 (EDT) |
civodul pushed a commit to branch core-updates
in repository guix.
commit da86e90efe796ee68ee0a5ccaf46f45cadb52336
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 a4e6590..526a21f 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
@@ -1844,6 +1845,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 834e78b..64c3107 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))))))
- 17/22: gnu: docbook-xsl: Move 'use-modules' form to the top level., (continued)
- 17/22: gnu: docbook-xsl: Move 'use-modules' form to the top level., guix-commits, 2021/03/30
- 15/22: gexp: Allowed/disallowed references and graphs never refer to grafted inputs., guix-commits, 2021/03/30
- 04/22: packages: Turn 'bag->derivation' into a monadic procedure., guix-commits, 2021/03/30
- 03/22: build-system: Rewrite using gexps., guix-commits, 2021/03/30
- 05/22: packages: Simplify patch instantiation., guix-commits, 2021/03/30
- 11/22: packages: '%standard-patch-inputs' is not influenced by '%current-target-system'., guix-commits, 2021/03/30
- 10/22: build-system: Use 'input-tuples->gexp' and 'outputs->gexp'., guix-commits, 2021/03/30
- 07/22: packages: Default origin 'patch-flags' is a gexp., guix-commits, 2021/03/30
- 12/22: packages: 'expand-input' accepts any file-like object., guix-commits, 2021/03/30
- 06/22: packages: Core procedures are written in monadic style., guix-commits, 2021/03/30
- 08/22: gexp: Add 'sexp->gexp'.,
guix-commits <=
- 18/22: gexp: 'imported+compiled-modules' fully honors #:guile., guix-commits, 2021/03/30
- 21/22: gnu: gnome-shell: Adjust to new #:disallowed-references convention., guix-commits, 2021/03/30
- 19/22: gexp: Add #:guile parameter to 'load-path-expression'., guix-commits, 2021/03/30
- 09/22: build-system: Use 'sexp->gexp' for plain sexps., guix-commits, 2021/03/30
- 14/22: grafts: Add 'without-grafting'., guix-commits, 2021/03/30
- 16/22: gexp: Do not add derivations to the object cache., guix-commits, 2021/03/30
- 22/22: gexp: 'compiled-modules' gets source and parameters an environment variables., guix-commits, 2021/03/30
- 20/22: gexp: 'gexp->script' uses #:guile also as the guile-for-build., guix-commits, 2021/03/30