guix-devel
[Top][All Lists]
Advanced

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

Re: New ‘--list-generations’ and ‘--delete-generations’ options


From: Ludovic Courtès
Subject: Re: New ‘--list-generations’ and ‘--delete-generations’ options
Date: Thu, 12 Sep 2013 14:26:16 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Nikita Karetnikov <address@hidden> skribis:

>> Probably this can reduce to a big ‘cond’, which would be even more
>> readable:
>
>>   (cond ((maybe-integer)
>>          =>
>>          list)
>>         ((string-match "^([0-9]+)\\.\\.([0-9]+)$" str)
>>          =>
>>          (lambda (match)
>>            ...))
>>         ...)
>
> Are you sure?  I haven’t found a way to make ‘cond’ as readable as ‘or’.

Yes, it makes it easier to enumerate all the cases, and to reason about it.

For instance, in ‘string->generations’, getting rid of ‘maybe-*-range’
and instead inlining the ‘string-match’ calls in ‘cond’ would greatly
clarify things IMO:

  (cond ((maybe-integer) ...)
        ((maybe-comma-separated-integers) ...)
        ((string-match p1 x) => ...)
        ((string-match p2 x) => ...)
        ((string-match p3 x) => ...)
        (else #f))

> I’m attaching a sketchy version.  If you don’t see any problems, I’ll
> try to integrate this code into ‘package.scm’.

I’d prefer clearer case analysis as shown above.

Thanks,
Ludo’.



reply via email to

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