Subject: Re: [PATCH v2 3/3] scripts: hash: Add git serializer.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 21 Dec 2021 10:09:01 +0100

Hi,

zimoun <[email-masked]> skribis:

> On Mon, 20 Dec 2021 at 14:40, Ludovic Courtès <[email-masked]> 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’.