From: Alex Kost <alezost@gmail.com>
To: Alex Vong <alexvong1995@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu: Add Mlucas.
Date: Tue, 06 Oct 2015 17:40:22 +0300 [thread overview]
Message-ID: <87h9m4f4bt.fsf@gmail.com> (raw)
In-Reply-To: <CADrxHD8+zYMw6us2taG7SU=XstU14etPMWwwY8OMMrkHbyucEg@mail.gmail.com> (Alex Vong's message of "Tue, 6 Oct 2015 21:43:14 +0800")
Alex Vong (2015-10-06 16:43 +0300) wrote:
> Hi Alex,
>
> On 06/10/2015, Alex Kost <alezost@gmail.com> 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
next prev parent reply other threads:[~2015-10-06 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-05 5:01 [PATCH] gnu: Add Mlucas Alex Vong
2015-10-05 10:46 ` Mathieu Lirzin
2015-10-06 3:13 ` Alex Vong
2015-10-06 10:04 ` Ludovic Courtès
2015-10-06 13:58 ` Alex Vong
2015-10-06 19:31 ` Ludovic Courtès
2015-10-06 15:06 ` Mathieu Lirzin
2015-10-06 15:31 ` Alex Kost
2015-10-05 16:42 ` Alex Kost
2015-10-06 13:43 ` Alex Vong
2015-10-06 14:40 ` Alex Kost [this message]
2015-10-06 19:28 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9m4f4bt.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=alexvong1995@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.