guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where the next effort in prolog will be and a cool match hack!!


From: Alex Shinn
Subject: Re: Where the next effort in prolog will be and a cool match hack!!
Date: Mon, 13 Sep 2010 11:32:13 +0900

On Fri, Sep 10, 2010 at 6:15 AM, Stefan Israelsson Tampe
<address@hidden> wrote:
>
> I just wanted to share some ideas that come to my mind to churn the prolog
> into something more useful.

Have you played with schelog and kanren?

> So I have been trying to rework Shins hygienic version if ice-9 match so that
> it can be used as a backbone for it.

[That's "Shinn" with two n's.]

> ;; defining xmatch utility - this just will use match but automatically fill 
> in
> ;; the header and make sure to use correct syntactic environment.
> ;; (make-phd-matcher name phd abs)
> ;; defaults is to use (*car ...), - means usual match will be done by (car 
> ...)
> ;; we also tell the matcher to use a set of abstractions with appropriate
> ;; variables to bind to. xmatch will be anaphoric though.

Right, a limitation of Wright's syntax is that "match" itself isn't
extensible, so to build on it you need to define syntax which
defines new pattern matchers.

The default matcher in Racket is extensible by dispatching
on the first symbol in each list, so a pair is (cons a b) and a
list would be (list a b c).  This is slightly more verbose, and
looks like how you would generate the data rather than its
actual structure, but at least is extensible.

It would be possible to build on Wright's syntax with a
single hook, e.g. patterns of the form

  (extended-match match-dispatcher data ...)

possibly abbreviated

  (: match-dispatcher data ...)

where `match-dispatcher' is an extension macro following
some CPS API.  A kludge, but perhaps better than
redefining a matcher for every extension.

-- 
Alex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]