From: Per Bothner <per@bothner.com>
To: kawa@sourceware.org
Subject: Re: ‘match’ and ‘!’ features
Date: Thu, 06 Sep 2018 17:10:00 -0000 [thread overview]
Message-ID: <b6ab5276-964e-bfde-7902-6331eccdd3ca@bothner.com> (raw)
In-Reply-To: <87ftym4ns7.fsf@gnu.org>
On 09/06/2018 09:02 AM, Mathieu Lirzin wrote:
> Hello,
>
> I am getting interested in using Kawa lately. I am happy to discover
> that it implements pattern matching using the âmatchâ and â!â macros.
> However I am a bit puzzled by the fact those features are added in the
> main module while the documentation on patterns [1] describe those
> features as work in progress.
>
> In order to lower the retro-compatibility expectations for those
> experimentations, What do you think of moving the âmatchâ and â!â
> definitions in a dedicated library for example (kawa match) ?
Moving these core features to library may be a bit of work, and
I don't think it would be desirable - as a core feature.
I'm reasonably comfortable with the syntax and design, and am not
planning on changing it. Of course there are almost certainly bugs as
well as under-optimized code.
The main feature where design and implementation are missing
is dealing with structural patterns.
Given a constructor function T, where T may be a type/class name
(see https://www.gnu.org/software/kawa/Allocating-objects.html),
what should be the pattern syntax for "destructuring"? The syntax
(T pat1 pat2 ... patN)
could be used to match a value created by (T e1 e2 ... eN)
by matching e1 against pat1 etc. There is a symmetry blemish in that T
in (T pat1 pat2 ... patN) is "evaluated" while the "arguments" are patterns,
but it still seems a reasonable syntax. Still, there are a number of
complications in doing this. Patterns with keyword arguments are slightly
easier. To match an obj against:
(T x: pat1 ... z: pat1)
could be implemented by matching obj:x against pat1 etc. In adddition
we should require (equal? obj (T obj:x ... obj:z)).
Then we could go further: Regular (tree) expressions. Strings.
XML/HTML nodes.
So that's what I mean when I say this feature is a work-in-progress.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
prev parent reply other threads:[~2018-09-06 17:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 16:02 Mathieu Lirzin
2018-09-06 17:10 ` Per Bothner [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6ab5276-964e-bfde-7902-6331eccdd3ca@bothner.com \
--to=per@bothner.com \
--cc=kawa@sourceware.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).