[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4] packages: Support for full Guix specification

From: Ricardo Wurmus
Subject: Re: [PATCH v4] packages: Support for full Guix specification
Date: Mon, 23 May 2022 23:02:53 +0200
User-agent: mu4e 1.6.10; emacs 28.0.50

Hi Olivier,

thank you for the updated patch!  Using object properties is a neat

> @@ -73,11 +77,18 @@
>  (define (lookup-package specification)
>    (log-event 'guix (G_ "Looking up package `~a'~%") specification)
> -  (match (lookup-inferior-packages (current-guix) specification)
> -    ((first . rest) first)
> -    (_ (raise (condition
> -               (&gwl-package-error
> -                (package-spec specification)))))))
> +  (let ((name version output
> +              (package-specification->name+version+output specification)))
> +    (let* ((inferior-package
> +            (lookup-inferior-packages (current-guix)
> +                                      name version))
> +           (package (match inferior-package
> +                      ((first . rest) first)
> +                      (_ (raise (condition
> +                                 (&gwl-package-error
> +                                  (package-spec specification))))))))

You can merge the SRFI-71 “let” with “let*” to a single “let*” and thus
remove one layer of nested parentheses.

> +      (set-object-property! package #:gwl/package-output output)

The Guile manual has this to say about “set-object-property!”:

       Guile also implements a more traditional Lispy interface to
    properties, in which each object has an list of key-value pairs
    associated with it.  Properties in that list are keyed by symbols.  This
    is a legacy interface; you should use weak hash tables or object
    properties instead.

The preferred way to do this is to define a property, and then use
“set!” and the property getter on the object:

--8<---------------cut here---------------start------------->8---
(define package-output (make-object-property))

(define* (lookup-package …)
 (set! (package-output package) output) ;store the output as a property


(package-output package) ; retrieve the output
--8<---------------cut here---------------end--------------->8---


reply via email to

[Prev in Thread] Current Thread [Next in Thread]