From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 43159@debbugs.gnu.org
Subject: [bug#43159] [PATCH 1/2] scripts: Use 'define-command' and have 'guix help' use that.
Date: Sun, 13 Sep 2020 15:03:04 +0200 [thread overview]
Message-ID: <87lfhd7rsn.fsf@gnu.org> (raw)
In-Reply-To: <878sdg6sz8.fsf@gmail.com> (Maxim Cournoyer's message of "Fri, 11 Sep 2020 14:58:19 -0400")
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> Sorry I couldn't reply faster.
No problem. I went ahead with this patch series, but nothing’s set in
stone and I’m open to further changes.
> Thanks for the detailed measurements! It does indeed seem your approach
> is better, especially considering memory usage. Perhaps the commands
> could have been moved to dedicated modules not using much dependency at
> all so that their closure would have been small hence fast to load, but
> keeping the commands definitions local to where they are useful is
> definitely a nice property.
We can’t really reduce the closure of commands. In particular, (guix
scripts system) has to load pretty much “everything”.
What we could do is use #:autoload aggressively in the (guix scripts …)
modules, such that startup time would be as small as possible—e.g.,
‘--help’ would not trigger loading of a zillion modules.
It’s a bit tedious though and not necessarily helpful in the general
case where one is doing something non-trivial with the command. Well
dunno, we could try!
>> In summary, while this approach undoubtedly looks awkward to any Lisper,
>> I think it’s a good way to not contribute to the general impression of
>> sluggishness and resource-hungriness of ‘guix’ commands. :-)
>>
>>>> + (define (display-commands commands)
>>>> + (let* ((names (map (lambda (command)
>>>> + (string-join (command-name command)))
>>>> + commands))
>>>> + (max-width (reduce max 0 (map string-length names))))
>>>
>>> You can drop reduce and use (max (map string-length names)) instead.
>>
>> I could do (apply max (map …)) but I don’t like the idea of abusing
>> variadic argument lists in that way—I know, it’s very subjective. ;-)
>
> Eh, I wonder why? I may be missing something, but if max allows it,
> doesn't it mean it's a valid use? Anyway, just curious to know what are
> the grounds for this personal preference :-).
It’s mostly aesthetic, but it comes from the idea that there could be
limitations on the maximum number of arguments a procedure can take, or
inefficiencies with dealing with many arguments. Now, in today’s Guile,
there are no such issues… (And now I look really silly!) :-)
Ludo’.
next prev parent reply other threads:[~2020-09-13 13:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 20:35 [bug#43159] [PATCH 0/2] Make 'guix help' helpful Ludovic Courtès
2020-09-01 20:41 ` [bug#43159] [PATCH 1/2] scripts: Use 'define-command' and have 'guix help' use that Ludovic Courtès
2020-09-01 20:41 ` [bug#43159] [PATCH 2/2] ui: '--help' output links to <https://guix.gnu.org/help/> Ludovic Courtès
2020-09-02 18:27 ` Maxim Cournoyer
2020-09-02 18:24 ` [bug#43159] [PATCH 1/2] scripts: Use 'define-command' and have 'guix help' use that Maxim Cournoyer
2020-09-03 13:41 ` Ludovic Courtès
2020-09-11 18:58 ` Maxim Cournoyer
2020-09-13 13:03 ` Ludovic Courtès [this message]
2020-09-13 23:33 ` Maxim Cournoyer
2020-09-07 12:56 ` [bug#43159] [PATCHES v2] " Ludovic Courtès
2020-09-10 10:34 ` bug#43159: " Ludovic Courtès
2020-09-10 10:55 ` [bug#43159] " Ricardo Wurmus
2020-09-02 8:06 ` [bug#43159] [PATCH 0/2] Make 'guix help' helpful Efraim Flashner
2020-09-02 9:50 ` Ludovic Courtès
2020-09-02 11:09 ` Efraim Flashner
2020-09-03 16:40 ` zimoun
2020-09-07 12:58 ` Ludovic Courtès
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=87lfhd7rsn.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=43159@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
/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).