2024-10-03 23:57:22 +00:00
|
|
|
= zexps
|
|
|
|
|
|
|
|
|
|
zexps, similar to g-expressions in Guix, are a way to generate
|
2024-10-04 01:21:07 +00:00
|
|
|
S-expressions that are tagged with store paths. The syntax in Zilch is inspired
|
|
|
|
|
by it, but has been developed separately.
|
2024-10-03 23:57:22 +00:00
|
|
|
|
2024-10-04 01:21:07 +00:00
|
|
|
A zexp is used similarly to a ``quasiquote``d value in Scheme, but has an extra type
|
|
|
|
|
of unquoting, called `zexp-unquote`, which unquotes a value such as a `++<store-path>++`
|
|
|
|
|
or another `zexp`.
|
2024-10-03 23:57:22 +00:00
|
|
|
|
2024-10-04 01:21:07 +00:00
|
|
|
Each `zexp` keeps track of the derivation outputs and store files it depends on,
|
|
|
|
|
similarly to how string context works in Nix:
|
2024-10-03 23:57:22 +00:00
|
|
|
|
|
|
|
|
[,scheme]
|
|
|
|
|
----
|
|
|
|
|
#~(foo bar #$baz)
|
|
|
|
|
; is identical to:
|
|
|
|
|
(zexp (foo bar (zexp-unquote baz)))
|
|
|
|
|
----
|
|
|
|
|
|
2024-10-04 01:21:07 +00:00
|
|
|
When a `zexp-unquote` (or its reader syntax, `#$`) is encountered, the value
|
|
|
|
|
contained in the `zexp` (or compatible object) is used as-is, with no
|
|
|
|
|
evaluation. It is possible to mix and match `zexp-unquote` with `unquote`,
|
|
|
|
|
allowing building e.g. dynamic strings from zexps. `zexp-unquote` is always
|
|
|
|
|
evaluated before `unquote` is.
|
2024-10-03 23:57:22 +00:00
|
|
|
|
|
|
|
|
[,scheme]
|
|
|
|
|
----
|
2024-10-04 01:21:07 +00:00
|
|
|
(define world ...)
|
|
|
|
|
(define hello #~("hello" ,(string-append "very " "cute" #$world)))
|
2024-10-03 23:57:22 +00:00
|
|
|
----
|