From: Sarah Morgensen <iskarian@mgsn.dev>
To: Xinglu Chen <public@yoctocell.xyz>
Cc: 50614@debbugs.gnu.org
Subject: [bug#50614] [PATCH core-updates] build: utils: Add ‘optional’ macro.
Date: Thu, 16 Sep 2021 17:37:24 -0700 [thread overview]
Message-ID: <864kakhwaj.fsf@mgsn.dev> (raw)
In-Reply-To: <b7ee7798dbf384021126a2cd4366b604730181b8.1631776133.git.public@yoctocell.xyz> (Xinglu Chen's message of "Thu, 16 Sep 2021 09:11:22 +0200 (17 hours, 10 minutes, 11 seconds ago)")
Hi,
Xinglu Chen <public@yoctocell.xyz> writes:
> * guix/build/utils.scm (optional): New syntax
> * tests/build-utils.scm ("optional: expr1 is non-#f", optional: expr1 is #f"):
> Test it.
> * guix.texi (Build Utilities): Document it.
> ---
> A common idiom I have seen is
>
> (if EXPR1
> EXPR2
> '())
>
> with the ‘optional’ macro, one can just write
>
> (optional EXPR1
> EXPR2)
>
> I am not sure if ‘optional’ is the best name (it was inspired by
> ‘lib.optional’ in Nixpkgs), feedback welcome!
I like the idea! But perhaps if we're getting rid of boilerplate, we
should go all the way and make it so that instead of
(if EXPR1
`(EXPR2 EXPR3)
'())
we can write
(optional EXPR1 EXPR2 EXPR3)
What do you think?
Also, maybe 'list-when' for the name?
> +@deffn {Scheme Syntax} optional @var{test} @var{consequent}
> +Like @code{when} (@pxref{Conditionals,,, guile, GNU Guile Reference
> +Manual}), but if @var{test} evaluates to false, return the empty list.
> +This is replaces the following idiom:
^ no "is"
> +@end deffn
> +
> +@lisp
> +(if @var{test}
> + @var{consequent}
> + '())
> +@end lisp
> +
> +with this:
> +
> +@lisp
> +(optional @var{test}
> + @var{consequent})
> +@end lisp
> +
> +It can be useful when certain targets require an additional configure
^ no "an"
> +flags, e.g.,
> +
> +@lisp
> +(arguments
> + `(#:configure-flags (list "--localstatedir=/var"
> + "--sysconfdir=/etc"
> + ,@@(optional (hurd-target?) '("--with-courage"))))
^ extra "@"?
--
Sarah
next prev parent reply other threads:[~2021-09-17 0:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 7:11 [bug#50614] [PATCH core-updates] build: utils: Add ‘optional’ macro Xinglu Chen
2021-09-16 16:21 ` Liliana Marie Prikler
2021-09-17 0:37 ` Sarah Morgensen [this message]
2021-09-17 8:26 ` [bug#50614] [PATCH] build: utils: Add ‘list-when’ macro Xinglu Chen
2021-09-17 17:55 ` Liliana Marie Prikler
2021-09-17 19:15 ` Sarah Morgensen
2021-09-17 19:31 ` Liliana Marie Prikler
2021-09-18 14:41 ` Maxime Devos
2021-09-19 13:38 ` Xinglu Chen
2021-09-17 19:19 ` Sarah Morgensen
2021-09-19 13:41 ` Xinglu Chen
2021-09-19 13:50 ` [bug#50614] [PATCH core-updates v2] " Xinglu Chen
2021-09-19 14:35 ` Maxime Devos
2021-09-20 11:03 ` [bug#50614] [PATCH core-updates] build: utils: Add ‘optional’ macro zimoun
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=864kakhwaj.fsf@mgsn.dev \
--to=iskarian@mgsn.dev \
--cc=50614@debbugs.gnu.org \
--cc=public@yoctocell.xyz \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).