Search code examples
schemeguileguix

What is #~ in scheme?


What does #~ mean in scheme (guile)?

For example in this snippet from the guix source code:

#~(list (string-append "prefix=" #$output))

Solution

  • Expanding upon @mnemenaut's comment, which set me on the correct track:

    According to the Guix Reference Manual, G-expressions are implemented in the (guix gexp) package.

    Here is an abstract that describes the #~ abbreviation, alongside #$ and #$@:

    G-expressions, or gexps, consist essentially of three syntactic forms: gexp, ungexp, and ungexp-splicing (or simply: #~, #$, and #$@), which are comparable to quasiquote, unquote, and unquote-splicing, respectively.

    So this abbreviation is not part of the Guile Scheme implementation (R5RS), but of the Guix API. It's no wonder it was so difficult to find in any source related to the language. When working with Guile, it may be worthwhile to merge the Guile Reference Manual, the Guix Reference Manual and the R5RS standard into a single HTML file.