Subject: Re: [bug#67489] [PATCH] monad-repl: Add REPL commands to inspect package arguments.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 28 Nov 2023 17:20:42 +0100

Hello!

Simon Tournier <[email-masked]> skribis:

> TLDR: All LGTM. :-)

Thanks.  :-)

> scheme@(guix-user)> ,pp (cdr (memq #:phases (package-arguments cava)))
> $3 = (#<gexp (modify-phases %standard-phases (replace (quote bootstrap) (lambda _ (setenv "HOME" (getcwd)) (invoke "sh" "autogen.sh"))) (add-before (quote build) (quote make-cava-ldflags) (lambda _ (mkdir-p (string-append #<gexp-output out> "/lib")))) (add-after (quote install) (quote data) (lambda _ (for-each (lambda (file) (install-file file (string-append #<gexp-output out> "/share/doc/examples"))) (find-files "example_files"))))) gnu/packages/audio.scm:5161:11 7f7258403a50>)
>
>
> Without drifting, why not the meta-command ,arguments? 

One can already do “,pp (package-arguments package)”, so I wanted to
have something short and to-the-point that would improve on that.

In particular, we know by convention that certain arguments can be
interpreted as code (gexps or sexps) so we can process them do display
them in a nice way (lowering gexps, applying the pretty printer).  We
cannot necessarily do that for other arguments where there’s no
established convention.

These REPL commands are really tailored for packagers.

> Here all is clear.  What can be confusing is the expansion of #$output
> as ((@ (guile) getenv) "out").  Maybe it could be worth to document this
> under G-expression section.  Or provide a similar example using
> G-expression under the section G-expression.
>
> Well, that’s unrelated to this patch and could be done separately. :-)

Yeah, we could/should document the implementation of #$output.

> Out of curiosity, what is the advantage for #:autoload versus
> #:use-module + #:select?

#:autoload allows modules to be loaded lazily, the first time one of the
selected symbols is used.  It’s a way to reduce startup time (equivalent
to Emacs autoloads).

>> +(define (keyword-argument-value args keyword default)
>> +  "Return the value associated with KEYWORD in ARGS, a keyword/value sequence,
>> +or DEFAULT if KEYWORD is missing from ARGS."
>> +  (let loop ((args args))
>> +    (match args
>> +      (()
>> +       default)
>> +      ((kw value rest ...)
>> +       (if (eq? kw keyword)
>> +           value
>> +           (loop rest))))))
>
>     ( Aside.  Each time, I am surprised that common helpers are not
>        Guile builtins, here for extracting keyword value.  It would help
>        Guile to provide such builtin, by default or via some ice-9
>        module.

Yeah, I was disappointed too.  :-)  (ice-9 optargs) has helpers that
weren’t a good match.

Thanks for your feedback!

Ludo’.