unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Add a way to disable serialization support to (guix services configuration)
Date: Wed, 21 Apr 2021 13:14:00 -0400	[thread overview]
Message-ID: <87eef3d0h3.fsf@gmail.com> (raw)
In-Reply-To: <87fszoswmc.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 17 Apr 2021 18:29:15 +0200")

Hello again,

Ludovic Courtès <ludo@gnu.org> writes:

[...]

> diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
> index 90f12a8d39..20e1647335 100644
> --- a/gnu/services/configuration.scm
> +++ b/gnu/services/configuration.scm
> @@ -109,6 +109,9 @@
>               (define (serialize-maybe-stem field-name val)
>                 (if (stem? val) (serialize-stem field-name val) ""))))))))
>
> +(define-syntax-parameter configuration-field-serialization?
> +  (identifier-syntax #t))
> +
>  (define-syntax define-configuration
>    (lambda (stx)
>      (syntax-case stx ()
> @@ -123,7 +126,8 @@
>                             #'(field-type ...)))
>                       ((field-serializer ...)
>                        (map (lambda (type)
> -                             (id #'stem #'serialize- type))
> +                             #`(and configuration-field-serialization?
> +                                    #,(id #'stem #'serialize- type)))
>                             #'(field-type ...))))
>             #`(begin
>                 (define-record-type* #,(id #'stem #'< #'stem #'>)
> @@ -152,6 +156,16 @@
>                                             #,(id #'stem #'stem #'-fields))
>                     conf))))))))
>
> +(define-syntax-rule (without-field-serialization definition)
> +  (syntax-parameterize ((configuration-field-serialization?
> +                         (identifier-syntax #f)))
> +    definition
> +    #t))
> +
> +(without-field-serialization
> +  (define-configuration foo
> +    (bar (integer 123) "doc")))
> +
>  (define (serialize-package field-name val)
>    "")

Actually, this doesn't seem to work; when exporting the
'without-field-serialization' from this module and using it in another
module (wrapping a (define-configuration ...) form), the compiler
complains that the 'foo' variable is not defined; perhaps because foo is
exported as part of the module definition?

If you have an idea why, hints welcome.

Maxim


      parent reply	other threads:[~2021-04-21 17:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 20:57 Add a way to disable serialization support to (guix services configuration) Maxim Cournoyer
2021-04-17 16:29 ` Ludovic Courtès
2021-04-21 15:43   ` Maxim Cournoyer
2021-04-22 22:28     ` Ludovic Courtès
2021-04-23  6:09       ` Xinglu Chen
2021-05-01 11:54         ` Xinglu Chen
2021-05-07  5:42           ` Maxim Cournoyer
2021-05-07 14:03             ` Xinglu Chen
2021-05-08  5:08           ` Maxim Cournoyer
2021-04-21 17:14   ` Maxim Cournoyer [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=87eef3d0h3.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@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).