gexp: Add 'sexp->gexp'.
* guix/gexp.scm (sexp->gexp): New procedure. * tests/gexp.scm ("sexp->gexp"): New test.
This commit is contained in:
parent
4f5f1d98ef
commit
da86e90efe
2 changed files with 18 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:export (gexp
|
#:export (gexp
|
||||||
gexp?
|
gexp?
|
||||||
|
sexp->gexp
|
||||||
with-imported-modules
|
with-imported-modules
|
||||||
with-extensions
|
with-extensions
|
||||||
let-system
|
let-system
|
||||||
|
@ -1844,6 +1845,16 @@ of name/gexp-input tuples, and OUTPUTS, a list of strings."
|
||||||
|
|
||||||
(ungexp body))))
|
(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
|
(define* (gexp->script name exp
|
||||||
#:key (guile (default-guile))
|
#:key (guile (default-guile))
|
||||||
(module-path %load-path)
|
(module-path %load-path)
|
||||||
|
|
|
@ -96,6 +96,13 @@
|
||||||
(null? (gexp-inputs exp))
|
(null? (gexp-inputs exp))
|
||||||
(gexp->sexp* 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"
|
(test-equal "unquote"
|
||||||
'(display `(foo ,(+ 2 3)))
|
'(display `(foo ,(+ 2 3)))
|
||||||
(let ((exp (gexp (display `(foo ,(+ 2 3))))))
|
(let ((exp (gexp (display `(foo ,(+ 2 3))))))
|
||||||
|
|
Reference in a new issue