unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Aleksandr Vityazev <avityazev@posteo.org>
Cc: guix-devel@gnu.org
Subject: Re: match-record
Date: Fri, 02 Dec 2022 22:45:32 +0100	[thread overview]
Message-ID: <87v8mtpjib.fsf@gnu.org> (raw)
In-Reply-To: <87o7sliqd0.fsf@posteo.org> (Aleksandr Vityazev's message of "Fri, 02 Dec 2022 18:59:23 +0000")

Hi Aleksandr,

Aleksandr Vityazev <avityazev@posteo.org> skribis:

> Before cc9ee514e37f6ec74dd9cab91a13d51f7b8d47e7 commit the code below
> worked:
>
> #+begin_src scheme :scheme guile :season guile
>
> (define (iwd-etc-service config)
>   (match-record config <iwd-configuration> (config)
>     `(("iwd/main.conf"
>        ,(apply mixed-text-file
>                "main.conf"
>                (serialize-ini-config config))))))
> #+end_src
>
>
> then this lead to an error:
> Syntax error:
> test.scm:109:44: lookup-field: unknown record type field in subform
> config of (lookup-field config (+ 1 (+ 1 (+ 1 0))) ())
>
>
> If you fix the code to the following one, it will work. 
>
> #+begin_src scheme :scheme guile :season guile
>
> (define (iwd-etc-service cfg)
>   (match-record cfg <iwd-configuration> (config)

[...]

> Should the code from the first block work, or should I not write it that
> way?

You have to write it that way.  (Though I would recommend a different
name for the field anyway, maybe ‘raw-file’?)

This is due to how “literals” are matched in syntax-{case,rules} (info
"(guile) Syntax Rules"):

     A literal matches an input expression if the input expression is an
  identifier with the same name as the literal, and both are unbound(1).

Here, because of the ‘config’ parameter, one of the two identifiers was
bound while the other is not, hence the match error.

HTH!

Ludo’.


      reply	other threads:[~2022-12-02 21:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 18:59 match-record Aleksandr Vityazev
2022-12-02 21:45 ` Ludovic Courtès [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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87v8mtpjib.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=avityazev@posteo.org \
    --cc=guix-devel@gnu.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 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).