"N. Y." <ningyuan...@gmail.com> writes:

> Hi all,
>
> I was wondering what is the meaning of symbols prefixed with "#$", for
> example "#$version" in Guix package definitions.

G-Expressions in Guix are created using #~<exp ...>, similar to how
S-Expressions are created using '<exp ...> or `<exp ...> in Scheme (and
other Lisps). The single quote in Scheme is actually a reader macro that
expands to the following:

'exp        => (quote exp)
'(exps ...) => (quote (exps ...))

Similarly, the backtick is a reader macro that expands to the following:

`exp        => (quasiquote exp)
`(exps ...) => (quasiquote (exps ...))

The latter is interesting because it allows us to /unquote/ data in the
S-expression, like so:

(let ((x 5)
      (y 6))
  (quasiquote (x (unquote x) y (unquote y)))) => (list 'x 5 'y 6)

I used the long form to avoid ambiguity, but that is the same as:

(let ((x 5)
      (y 6))
  `(x ,x y ,y)) => (list 'x 5 'y 6)

Where the comma is used as the unquote reader macro.

I apologize if this is review for you, but it's important to say because
this is exactly what is happening with #~ and #$. They are both reader
macros, that behave similarly to the quasiquote and unquote reader
macros: ` and ,.

(let ((x 5)
      (y 6))
  #~(x #$x y #$y))

Is the same as:

(let ((x 5)
      (y 6))
  (gexp (x (ungexp x) y (ungexp y))))

After expanding the reader macros.

I'm not sure about your package error, but I hope this helps point you
in the right direction :-)

Robby

Reply via email to