GNU bug report logs - #57643
[PATCH 0/3] Document the image API.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <othacehe <at> gnu.org>

Date: Wed, 7 Sep 2022 12:46:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #44 received at 57643 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Mathieu Othacehe <othacehe <at> gnu.org>, 57643 <at> debbugs.gnu.org
Subject: Re: [bug#57643] [PATCH 1/3] image: Make the operating-system field
 mandatory.
Date: Sat, 24 Sep 2022 12:55:37 +0200
[Message part 1 (text/plain, inline)]

On 07-09-2022 14:46, Mathieu Othacehe wrote:
> +(define-syntax image-without-os
> +  (lambda (x)
> +    "Return an image record with the mandatory operating-system field set to
> +#false.  This is useful when creating an image record that will serve as a
> +parent image record > +
> +    (define (maybe-cons field acc)
> +      ;; Return the given ACC list if FIELD is 'operating-system or the
> +      ;; concatenation of FIELD to ACC otherwise.
> +      (syntax-case field ()
> +        ((f v)
> +         (if (eq? (syntax->datum #'f) 'operating-system)
> +             acc
> +             (cons field acc)))) > +
> +    (syntax-case x (image)
> +      ;; Remove the operating-system field from the defined fields and then
> +      ;; force it to #false.
> +      ((_ fields ...)
> +       (let loop ((fields #'(fields ...))
> +                  (acc   '()))
> +         (syntax-case fields ()
> +           ((last)
> +            #`(image
> +               ;; Force it to #false.
> +               (operating-system #false)
> +               #,@(maybe-cons #'last acc)))
> +           ((field rest ...)
> +            (loop #'(rest ...) (maybe-cons #'field acc)))))))))

The complexity of this 'without os' macro seems to come from accepting 
an 'os' and then throwing it away.  However, when there is an 'os', you 
might as well use 'image' directly, without 'image-without-os', so I 
think this macro can be simplified to:

(define-syntax-rule (image-without-os . settings)
  "docstring"
  (image (operating-system #false) . settings))

(IIUC, '(guix records)' will detect duplicate definitions of fields.)

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 2 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.