guix-patches
[Top][All Lists]
Advanced

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

[bug#51307] [PATCH v2 3/3] scripts: hash: Add git serializer.


From: Ludovic Courtès
Subject: [bug#51307] [PATCH v2 3/3] scripts: hash: Add git serializer.
Date: Tue, 21 Dec 2021 10:09:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> On Mon, 20 Dec 2021 at 14:40, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> > +  #:use-module ((disarchive git-hash) #:select (git-hash-file
>> > +                                                git-hash-directory))
>>
>> Use #:autoload (that makes Disarchive a soft dependency and also reduces
>> start-up time.)
>
> Thanks.  As I asked in the cover-letter, these are confusing for me.
> For instance, why not autoloading all the used modules?  And is it
> better to lazily load with something like:
>
>   (match (and=> (resolve-module '(disarchive) #:ensure #f)
>                 (lambda (disarchive)
>                   (cons (module-ref disarchive '%disarchive-log-port)
>                         (module-ref disarchive 'disarchive-assemble))))
>     (#f (format #t "could not load Disarchive~%")
>         #f)
>     ((%disarchive-log-port . disarchive-assemble)
>
> ?  From guix/build/download.scm, or any other "lazy reference" in the code 
> code.
>
> What are the differences?  I have read the documentation but it is not
> clear for me the difference between '#:autoload' and 'module-ref'.

There are several reasons for autoloading: one is startup time/memory
footprint, and another one is having “soft dependencies” (you can still
build and use the thing when the dependency is missing; only that
specific feature is unavailable.)

Usually we’d use #:autoload, but in cases where we want full control
over the process, as in the Disarchive snippet you show above, we’d use
the programmatic interface.

There are also cases of “lazy references” where we use the programmatic
interface to load things at run time.  This is used for instance to keep
(guix …) modules independent of (gnu …) modules.

I hope this sheds some light!

>> I was wondering whether we should keep the deprecation warning for ‘-r’;
>> we might consider it a handy shorthand for ‘-S nar’?
>
> Ah, yes.  Deprecate '--recursive' but keep '-r' as shorthand for '-S
> nar'.  LGTM.

I’d treat ‘-r’ and ‘--recursive’ in the same way, no?  That is, keep
them both without a deprecation warning, but document them as aliases
for ‘-S nar’.  WDYT?

Thanks,
Ludo’.





reply via email to

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