From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: fmatch
Date: Sun, 20 Jun 2010 23:56:14 +0200 [thread overview]
Message-ID: <87pqzls70h.fsf@gnu.org> (raw)
In-Reply-To: 201006202158.59070.stefan.tampe@spray.se
Hi!
stefan <stefan.tampe@spray.se> writes:
> I think that the match-define logic is something that is missing in the
> Shinn version although I don't know how much this construct is used.
Yes, I left a comment about it in ice-9/match.scm.
> Basically $ is using the order of the records like ($ person? Rec1 Rec2 , ...
> Recn)
> and is nice to do quick hacks and get dense informative matchers. On the
> other hand if the record specification changes, like the order of the
> records or meanings etc havoc can enter. So destructuring on order would
> probably, in the end, yield a buggy code base. And I suspect that this issue
> makes the $ construct less liked and probably will not be accepted upstreams.
>
> On the other hand we have the record-case construct that is somewhat dense in
> information but is not hygienic. That would leave us with constructs like
>
> (and (= person-height pat1)
> (= person-weight pat2)
> ...)
>
> We can streamline it a little but the end win is marginal compared to the
> size of usual accessor names.
It looks like we are somewhere between a rock and a hard place. :-)
> I would have liked something like
> ($ person (height pat1) (weight pat2))
Perhaps:
($ person? (person-height h) (person-weight w))
But then again, if we look at, say, language/tree-il/analyze.scm as an
example, it seems clear that such a syntax would be too heavyweight.
In Coq, OCaml, Scala, etc., one matches on the type constructor:
match stefan with
| Person h w => ...
end
This *is* also positional matching, except that it relates to the
position of the arguments to the constructor, not to the position of
slots within the structure. In the end, it’s not too different, though.
So, I’m still in favor of adding Wright’s ‘$’ positional pattern
matching, along with ‘=’ to match with named accessors.
Thanks,
Ludo’.
prev parent reply other threads:[~2010-06-20 21:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-06 20:39 fmatch stefan
2010-05-07 11:59 ` fmatch Ludovic Courtès
2010-05-07 14:24 ` fmatch stefan
2010-05-07 20:23 ` fmatch Ludovic Courtès
2010-05-07 20:53 ` fmatch stefan
2010-05-09 20:57 ` fmatch Ludovic Courtès
2010-05-09 20:52 ` fmatch stefan
2010-05-10 8:26 ` fmatch Ludovic Courtès
2010-05-11 14:26 ` fmatch Stefan
2010-05-17 20:08 ` fmatch stefan
2010-05-22 21:03 ` fmatch Ludovic Courtès
2010-05-22 21:31 ` fmatch stefan
2010-05-23 16:06 ` fmatch Ludovic Courtès
2010-05-23 15:47 ` fmatch stefan
2010-05-24 20:08 ` fmatch Ludovic Courtès
2010-05-24 21:05 ` fmatch stefan
2010-05-25 17:41 ` fmatch Ludovic Courtès
2010-05-25 21:10 ` fmatch stefan
2010-06-16 21:31 ` fmatch Ludovic Courtès
2010-06-20 19:58 ` fmatch stefan
2010-06-20 21:56 ` Ludovic Courtès [this message]
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pqzls70h.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).