* ‘match’ and ‘!’ features
@ 2018-09-06 16:02 Mathieu Lirzin
2018-09-06 17:10 ` Per Bothner
0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Lirzin @ 2018-09-06 16:02 UTC (permalink / raw)
To: kawa
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) ?
[1] https://www.gnu.org/software/kawa/Variables-and-Patterns.html
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ‘match’ and ‘!’ features
2018-09-06 16:02 ‘match’ and ‘!’ features Mathieu Lirzin
@ 2018-09-06 17:10 ` Per Bothner
0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2018-09-06 17:10 UTC (permalink / raw)
To: kawa
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-06 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 16:02 ‘match’ and ‘!’ features Mathieu Lirzin
2018-09-06 17:10 ` Per Bothner
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).