From: Simon Tournier <zimon.toutoune@gmail.com>
To: Carlo Zancanaro <carlo@zancanaro.id.au>
Cc: "Guix Devel" <guix-devel@gnu.org>, "Ludovic Courtès" <ludo@gnu.org>
Subject: Re: ice-9 match penalty depending on pattern?
Date: Wed, 07 Feb 2024 10:22:03 +0100 [thread overview]
Message-ID: <87h6ikvdc4.fsf@gmail.com> (raw)
In-Reply-To: <87il31upn1.fsf@zancanaro.id.au>
Hi,
On mer., 07 févr. 2024 at 10:41, Carlo Zancanaro <carlo@zancanaro.id.au> wrote:
>> Why not? Do I miss something in the implementation of ’match’?
>
> The only reason I can think of would be if these matches are sometimes
> provided improper lists, which need to fail these match conditions. That
> seems unlikely to me, but it should be clear from looking at the other
> match clauses in each case.
Well, I have not pruned the list returned by just grepping. :-) And I
have just grepped with the term ’head’, ’tail’ and ’\.\.\.’
Somehow, my question is twofold:
1. Is the “expensive” check worth for such case:
(match paths
((head tail ...)
(if (visited? head)
(loop tail visited result)
(call-with-values
(lambda ()
(loop (references store head)
(visit head)
result))
(lambda (visited result)
(loop tail
visited
(cons head result))))))
(()
(values visited result)))))
seen in ’topologically-sorted’ procedure from (guix store) module.
2. Is the “expensive” check worth for such multi-cases:
(match sexp
((? string? str)
(let ((prefix "swh:1:dir:"))
(if (string-prefix? prefix str)
(cons (string-drop str (string-length prefix)) ids)
ids)))
((head tail ...)
(loop tail (loop head ids)))
(_ ids))
seen in ’lookup-disarchive-spec’ from (guix lint).
Well, I am not saying to rely on ’car’ and ’cdr’. Instead, I am asking
what is the idiomatic Guile pattern matching for Guile?
My main concern is about chasing the unnecessary checks for making Guix
a bit faster. :-)
Cheers,
simon
next prev parent reply other threads:[~2024-02-11 17:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 21:33 ice-9 match penalty depending on pattern? Simon Tournier
2024-02-06 23:41 ` Carlo Zancanaro
2024-02-07 9:22 ` Simon Tournier [this message]
2024-02-24 16:27 ` 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=87h6ikvdc4.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=carlo@zancanaro.id.au \
--cc=guix-devel@gnu.org \
--cc=ludo@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.