unofficial mirror of gwl-devel@gnu.org
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: zimoun <zimon.toutoune@gmail.com>
Cc: gwl-devel@gnu.org
Subject: Re: variable interpolation in code snippets
Date: Fri, 07 Jun 2019 16:59:51 +0200	[thread overview]
Message-ID: <87d0jpjva0.fsf@elephly.net> (raw)
In-Reply-To: <87r28airk4.fsf@elephly.net>


Ricardo Wurmus <rekado@elephly.net> writes:

>> It improves the readibilty.
>> However, does the keyword `list` is mandatory ?
>
> Unfortunately it is mandatory.  Previously, I tried to give the record
> field a “smart constructor” that takes either one value (a list or a let
> binding resulting in a list) or — for convenience – multiple values that
> are then turned into a list.
>
> With the Guix-style records this does not seem to be possible.  If we
> want to make this work we’d have to use our own extended records or
> maybe switch to GOOPS.  GOOPS offers virtual slots that can have
> slot-ref and slot-set! procedures, which would handle the conversion
> transparently.  I think this would be a good way forward — and it would
> decouple the GWL from the Guix version in use, because those extended
> record are really made for Guix and may not forever match the needs of
> the GWL.

We’re now using GOOPS for the <process> type.  I implemented field
validation and implicit lists, so this is now possible:

--8<---------------cut here---------------start------------->8---
process: run-bash
  package-inputs "bash"
  data-inputs
    . "a"
    . #:awesome "b"
    . "c"
  procedure # bash {
    echo "The name of this process: {{name}}."
    echo "The most awesome of the data inputs is: {{data-inputs:awesome}}."
  }
--8<---------------cut here---------------end--------------->8---

The dots are necessary to continue broken lines, but it’s also fine to
put everything on one line:

   data-inputs "a" #:awesome "b" "c"

With a reader option we could shave off one more character from the
keyword syntax and use this instead:

   data-inputs "a" :awesome "b" "c"

Lists are still valid, of course, they are just optional:

   data-inputs : list "a" :awesome "b" "c"

or

   data-inputs
     list "a" :awesome "b" "c"

--
Ricardo

      parent reply	other threads:[~2019-06-07 15:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 14:50 variable interpolation in code snippets Ricardo Wurmus
2019-02-25 23:00 ` zimoun
2019-02-26  8:12   ` Ricardo Wurmus
2019-02-26 17:35     ` zimoun
2019-02-26 19:04       ` Ricardo Wurmus
2019-02-26 19:29         ` zimoun
2019-05-29 13:27           ` Ricardo Wurmus
2019-06-03 14:54             ` zimoun
2019-06-03 16:04               ` Ricardo Wurmus
2019-06-03 18:19                 ` Roel Janssen
2019-06-07 14:59                 ` Ricardo Wurmus [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

  List information: https://www.guixwl.org/

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

  git send-email \
    --in-reply-to=87d0jpjva0.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=gwl-devel@gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /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.
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).