guix-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] gnu: Add Mlucas.


From: Alex Kost
Subject: Re: [PATCH] gnu: Add Mlucas.
Date: Tue, 06 Oct 2015 17:40:22 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Alex Vong (2015-10-06 16:43 +0300) wrote:

> Hi Alex,
>
> On 06/10/2015, Alex Kost <address@hidden> wrote:
[...]
>>> +;;; selectors of flag-sublist
>>> +(define (flag-type flag-sublist)
>>> +  (car flag-sublist))
>>> +(define (flag-string-list flag-sublist)
>>> +  (cdr flag-sublist))
>>
>> IMO it is clearer to write it like this:
>>
>>   (define flag-type first)
>>   (define flag-string-list second)
>>
>> Although I think it is better to use records for such things.  We also
>> have 'define-record-type*' in (guix records) module.
>>
>> (also some people don't like car/cdr with passion)
>>
> I think SECOND is CADR instead of CDR. Am I right? I will read about
> DEFINE-RECORD-TYPE, it sounds fun to define new types.

Ouch, yes, 'second' is 'cadr', my bad.  Actually I think 'first',
'second', etc. are not much better then 'car', 'cadr', etc.  It is
usually possible and desirable to avoid such things, although I confess
I use 'car'-s sometimes (when Ludovic doesn't see :-)).

>>> +;;; constructor of flag-list
>>> +(define (flag-list . flag-lst)
>>> +  ;; Trim leading and trailing whitespaces of all flag-string
>>> +  ;; in flag-list.
>>> +  (define (trim-flag-string flag-lst)
>>> +    (map (λ(flag-sublist)
>>
>> We use 'lambda'.  I'm personally not against 'λ', but maybe others
>> wouldn't like it.  Anyway a common convention is to have a space before
>> "(", i.e.:
>>
>>   (map (λ (flag-sublist) ...))
>>
> I used to use LAMBDA, but one day I discovered Guile supports λ, so I
> have used it since then. I will follow the space convention anyway.

I like "λ" and I will use it too, if it is (will be) allowed.  Thanks
for raising this.

[...]
>> And absolutely all people don't like 'cadadr'!!  Please use 'match' for
>> such things:
>> <https://www.gnu.org/software/guile/manual/html_node/Pattern-Matching.html>.
>>
> Yes, (second (second ...) is probably better than cadadr. I should
> really try pattern matcher. Do you know any tutorial on it? However, I
> think I am not making a new build system anymore. The reason will be
> noted on the next reply.

I've never searched for a tutorial.  I learnt how to use 'match' from
the Guile manual and the Guix source code.  There is also a cool
'match-lambda' macro which can be often met in the Guix code, but it is
not documented in the Guile manual.

-- 
Alex



reply via email to

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