all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Wojtek Kosior via <help-guix@gnu.org>
To: jgart <jgart@dismail.de>
Cc: Guix Help <help-guix@gnu.org>
Subject: Re: doubly quoted list in gnu-build
Date: Wed, 7 Dec 2022 08:10:33 +0100	[thread overview]
Message-ID: <20221207081033.5abcf461.koszko@koszko.org> (raw)
In-Reply-To: <20221207001451.GB32178@dismail.de>

[-- Attachment #1: Type: text/plain, Size: 3782 bytes --]

> hi,
> 
> why do the configure-flags and make-flags need to be doubly quote in the gnu-build procedure?

Because later in that function they get unquoted inside a gexp using
`#$` (i.e. `ungexp`).

If you write a gexp like

> (let ((somelist '("a" "b" "c")))
>   #~(display #$somelist))

on the build side it will resolve to

> (display ("a" "b" "c"))

which will of course fail because `"a"` is not a proper function. You
instead want to get this

> (display '("a" "b" "c"))

which can be achieved by e.g. double-quoting the value that gets
ungexp'd, e.g. with

> (let ((somelist ''("a" "b" "c")))
>   #~(display #$somelist))

The following should also work for this list

> (let ((somelist '("a" "b" "c")))
>   #~(display '#$somelist))

In many places in Guix code a function `sexp->gexp` is also used
together with `'#$`. I suspect it does some extra stuff. I don't know
what exactly.

The relevant part where those double-quoted lists are used is

>                            #:locale #$locale
>                            #:bootstrap-scripts #$bootstrap-scripts
>                            #:configure-flags #$(if (pair? configure-flags)
>                                                    (sexp->gexp configure-flags) ; here
>                                                    configure-flags)
>                            #:make-flags #$(if (pair? make-flags)
>                                               (sexp->gexp make-flags)           ; here
>                                               make-flags)
>                            #:out-of-source? #$out-of-source?
>                            #:tests? #$tests?
>                            #:test-target #$test-target

When a double-quoted list is used, the "true" expression of each `if`
clause is used :)

Wojtek

-- (sig_start)
website: https://koszko.org/koszko.html
PGP: https://koszko.org/key.gpg
fingerprint: E972 7060 E3C5 637C 8A4F  4B42 4BC5 221C 5A79 FD1A

Meet Kraków saints!           #46: saint Stanisław Papczyński
Poznaj świętych krakowskich!  #46: święty Stanisław Papczyński
https://pl.wikipedia.org/wiki/Stanisław_Papczyński
-- (sig_end)


On Wed, 7 Dec 2022 00:14:51 -0600
jgart <jgart@dismail.de> wrote:

> hi,
> 
> why do the configure-flags and make-flags need to be doubly quote in the gnu-build procedure?
> 
> (define* (gnu-build name inputs
>                     #:key
>                     guile source
>                     (outputs '("out"))
>                     (search-paths '())
>                     (bootstrap-scripts %bootstrap-scripts)
>                     (configure-flags ''()) ; here
>                     (make-flags ''()) ; here
>                     (out-of-source? #f)
>                     (tests? #t)
>                     (test-target "check")
>                     (parallel-build? #t)
>                     (parallel-tests? #t)
>                     (patch-shebangs? #t)
>                     (strip-binaries? #t)
>                     (strip-flags %strip-flags)
>                     (strip-directories %strip-directories)
>                     (validate-runpath? #t)
>                     (make-dynamic-linker-cache? #t)
>                     (license-file-regexp %license-file-regexp)
>                     (phases '%standard-phases)
>                     (locale "en_US.utf8")
>                     (system (%current-system))
>                     (build (nix-system->gnu-triplet system))
>                     (imported-modules %gnu-build-system-modules)
>                     (modules %default-modules)
>                     (substitutable? #t)
>                     allowed-references
>                     disallowed-references)
> 
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2022-12-07  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  6:14 doubly quoted list in gnu-build jgart
2022-12-07  7:10 ` Wojtek Kosior via [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221207081033.5abcf461.koszko@koszko.org \
    --to=help-guix@gnu.org \
    --cc=jgart@dismail.de \
    --cc=koszko@koszko.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.