guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is wrong with these few lines of guile code?


From: Ricardo Wurmus
Subject: Re: What is wrong with these few lines of guile code?
Date: Fri, 03 Nov 2017 17:09:35 +0100
User-agent: mu4e 0.9.18; emacs 25.3.1

Hartmut Goebel <address@hidden> writes:

> Am 31.10.2017 um 18:50 schrieb Christopher Baines:
>> This matches the error you're getting, as #~ is short for (gexp ...) as
>> I understand it.
>
> Thanks you, this did the trick :-) Although this reminds my on the magic
> signs in perl :-(

It’s a reader macro.  They all start with # and are followed by a
character.  You can install a reader macro to transform the expression
as it is read.  For example, I used a reader macro in earlier versions
of my operating system configuration so that I can avoid wrapping file
contents in string quotes.

Reader macros are frowned upon when they are added for no good reason.

A reader macro is used here, because to Schemers it comes natural to use
syntax like “`” (quasiquote), “'” (quote), “,” (unquote), and “,@”
(unquote-splicing).  Gexps are analogous to quoted S-expressions, so
(gexp …) “quotes” and (ungexp …) unquotes, etc.  The reader extensions
positively affect readability as they strip off one layer of
parenthetical expressions, at the cost of extra syntax.

For more information on the thinking behind Gexps and their relation to
quasiquotation see Ludo’s excellent paper “Code Staging in GNU Guix”,
available at <https://hal.inria.fr/hal-01580582/en>.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]