From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id HidSN1ysXl+7JAAA0tVLHw (envelope-from ) for ; Sun, 13 Sep 2020 23:33:48 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AGIXMVysXl/mIAAAbx9fmQ (envelope-from ) for ; Sun, 13 Sep 2020 23:33:48 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5D4C89404C3 for ; Sun, 13 Sep 2020 23:33:48 +0000 (UTC) Received: from localhost ([::1]:42694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHbVD-0003Iq-Cw for larch@yhetil.org; Sun, 13 Sep 2020 19:33:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHbUT-0002d6-Tt for guix-patches@gnu.org; Sun, 13 Sep 2020 19:33:01 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHbUT-0000z9-Jp for guix-patches@gnu.org; Sun, 13 Sep 2020 19:33:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kHbUT-0004zC-HM for guix-patches@gnu.org; Sun, 13 Sep 2020 19:33:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43159] [PATCH 1/2] scripts: Use 'define-command' and have 'guix help' use that. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Sep 2020 23:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43159 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 43159@debbugs.gnu.org Received: via spool by 43159-submit@debbugs.gnu.org id=B43159.160003996719145 (code B ref 43159); Sun, 13 Sep 2020 23:33:01 +0000 Received: (at 43159) by debbugs.gnu.org; 13 Sep 2020 23:32:47 +0000 Received: from localhost ([127.0.0.1]:52059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHbUF-0004yj-Fn for submit@debbugs.gnu.org; Sun, 13 Sep 2020 19:32:47 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHbUB-0004tR-Qs for 43159@debbugs.gnu.org; Sun, 13 Sep 2020 19:32:45 -0400 Received: by mail-qt1-f193.google.com with SMTP id t20so12183335qtr.8 for <43159@debbugs.gnu.org>; Sun, 13 Sep 2020 16:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=wZaDZOGMYWX1Tb0X0p1o2625CCn0dC3wE7aQsLTn2Zg=; b=FGlbjHJrZmeRIKsYGYOAuI24kOr6v82YHXfjrGZ4tUFd/NtlWPgABpcLVv5ajjJsNb KR4YBFr+mZvF7h+yfTRxL9C7zBQOJ486u/KAfLsDTN5lLf6Lab2Xl78UHn2+VIBr8BEk Vlbp+sqJjBw3JJ+SK0JmfyCTITVBxX/DFZIFlB3+P3bweDNSNldBaq6zoI4Kw2hSNx8L HX+nnkewlbKjUWZfmkVJdUMQzkj6cloqy2DcQ6YQ6ciKfePYZjwj469XQVDv6TtvO1eP OzVmy45BGQtM14JUSUSrmC9+5SPDSOne9v0sfEjaiic7I7ayQgihk+VbdV6ehZmulS9d y6Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=wZaDZOGMYWX1Tb0X0p1o2625CCn0dC3wE7aQsLTn2Zg=; b=PjFuuamDxhKQNj4YN9IXJaUNX7CuBhesdkgg32EKLdorVM3a6qxtjnExoldAUWHO1D Fx5ylxI0k+eznMyqXBJh9S/W5D+g/ZC0UhyjM5ObdFeYXxy9rHsmcX/OXCK8WXhtmfl7 gb1BeOPUJFIdb5bKehoAAkomROpcKGiLq5y5+to4JWjNCvPKCZbmJajGFblhA2NHsE8I 1SVl40DZW2JJwU9KGMHF8FB4k1esUGLu+xt2Qa40m+vrEy70/H4AFxOulenoyVi0X1zs fvqoXv1R0rgwYT9a79ahkg7WWsuL7ZDBiEQC8k/HE6GPY/1KlzN7oTu/dnfSFuPnKCT2 flCQ== X-Gm-Message-State: AOAM532kir8wLpqiJ6vpRYlTT3bWC3mWDfspLr0R3CABs5RhMBvbW++a WYsfdS46zI1Vr1VNOprukkgvtyhiZ/E= X-Google-Smtp-Source: ABdhPJzI5G7KOTCYJ8R5nOrb+iFiirDc2yIgNC6oS0PImFK+wVyfRe+fZKaUImzkY6cP6TpESskOMQ== X-Received: by 2002:ac8:748c:: with SMTP id v12mr10582566qtq.200.1600039957952; Sun, 13 Sep 2020 16:32:37 -0700 (PDT) Received: from hurd (dsl-205-233-124-4.b2b2c.ca. [205.233.124.4]) by smtp.gmail.com with ESMTPSA id s15sm12756237qke.134.2020.09.13.16.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 16:32:37 -0700 (PDT) From: Maxim Cournoyer References: <20200901203520.21103-1-ludo@gnu.org> <20200901204136.21375-1-ludo@gnu.org> <87r1rk595p.fsf@gmail.com> <87blinx9ii.fsf@gnu.org> <878sdg6sz8.fsf@gmail.com> <87lfhd7rsn.fsf@gnu.org> Date: Sun, 13 Sep 2020 19:33:24 -0400 In-Reply-To: <87lfhd7rsn.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Sun, 13 Sep 2020 15:03:04 +0200") Message-ID: <87wo0x5k1n.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=FGlbjHJr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: yYMs/uIVyGYu Hi Ludovic! Ludovic Court=C3=A8s writes: > Hi, > > Maxim Cournoyer skribis: > >> Sorry I couldn't reply faster. > > No problem. I went ahead with this patch series, but nothing=E2=80=99s s= et in > stone and I=E2=80=99m open to further changes. No problem! I'm glad this nice UI improvement has already landed. >> 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=E2=80=99t really reduce the closure of commands. In particular, (= guix > scripts system) has to load pretty much =E2=80=9Ceverything=E2=80=9D. > > What we could do is use #:autoload aggressively in the (guix scripts =E2= =80=A6) > modules, such that startup time would be as small as possible=E2=80=94e.g= ., > =E2=80=98--help=E2=80=99 would not trigger loading of a zillion modules. > > It=E2=80=99s a bit tedious though and not necessarily helpful in the gene= ral > case where one is doing something non-trivial with the command. Well > dunno, we could try! Seems like too much micro-management. This further solidifies your design choice as the right one :-). >>> In summary, while this approach undoubtedly looks awkward to any Lisper, >>> I think it=E2=80=99s a good way to not contribute to the general impres= sion of >>> sluggishness and resource-hungriness of =E2=80=98guix=E2=80=99 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 =E2=80=A6)) but I don=E2=80=99t like the ide= a of abusing >>> variadic argument lists in that way=E2=80=94I know, it=E2=80=99s very s= ubjective. ;-) >> >> 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=E2=80=99s mostly aesthetic, but it comes from the idea that there coul= d be > limitations on the maximum number of arguments a procedure can take, or > inefficiencies with dealing with many arguments. Now, in today=E2=80=99s= Guile, > there are no such issues=E2=80=A6 (And now I look really silly!) :-) Ha! Thanks for explaining. Now I know I can shamelessly continue using apply on procedures accepting N arguments :-). Maxim