From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: Where the next effort in prolog will be and a cool match hack!! Date: Mon, 13 Sep 2010 20:45:22 +0200 Message-ID: <201009132045.22086.stefan.tampe@spray.se> References: <201009092315.02287.stefan.tampe@spray.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1284403828 28436 80.91.229.12 (13 Sep 2010 18:50:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Sep 2010 18:50:28 +0000 (UTC) Cc: guile-devel@gnu.org To: Alex Shinn Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 13 20:50:26 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OvE6h-0000se-GI for guile-devel@m.gmane.org; Mon, 13 Sep 2010 20:50:23 +0200 Original-Received: from localhost ([127.0.0.1]:58443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvE6g-0005dK-Nb for guile-devel@m.gmane.org; Mon, 13 Sep 2010 14:50:22 -0400 Original-Received: from [140.186.70.92] (port=39589 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvE3I-0003fw-Rj for guile-devel@gnu.org; Mon, 13 Sep 2010 14:46:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvE3H-0001S4-CC for guile-devel@gnu.org; Mon, 13 Sep 2010 14:46:52 -0400 Original-Received: from spsmtp02oc.mail2world.com ([74.202.142.198]:2725) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvE3H-0001Ee-4k for guile-devel@gnu.org; Mon, 13 Sep 2010 14:46:51 -0400 Original-Received: from mail pickup service by spsmtp02oc.mail2world.com with Microsoft SMTPSVC; Mon, 13 Sep 2010 11:45:16 -0700 auth-sender: stefan.tampe@spray.se Original-Received: from 82.182.254.46 unverified ([82.182.254.46]) by spsmtp02oc.mail2world.com with Mail2World SMTP Server; Mon, 13 Sep 2010 11:45:15 -0700 User-Agent: KMail/1.13.5 (Linux/2.6.34-12-desktop; KDE/4.4.4; x86_64; ; ) In-Reply-To: X-OriginalArrivalTime: 13 Sep 2010 18:45:16.0016 (UTC) FILETIME=[CE72B700:01CB5373] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10911 Archived-At: Hi Alex, On Monday, September 13, 2010 04:32:13 am Alex Shinn wrote: > On Fri, Sep 10, 2010 at 6:15 AM, Stefan Israelsson Tampe > > 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? Yeah, I looked briefly at schelog. I'm trying to have both a shelog like version to code as well the possibility to link in code written in pure prolog. Then there is a C-backend which I play with quite severly investigating intersting extensions to prolog. Like the ability to handle a massive number of continuations sharing state in a compact way e.g. compress the redo tree. The speed is ok and on par with non compiled gprolog programs (probably wam bytecode). Also being guile centric, hence today leads to quite dramatic speedups using a C backend with the drawback of complicating life :-) Anyhow my view is that at the heart of a prolog system lies a matcher, just like yours, where one just have redefined car,cdr,pair?,null? and equal? Ontop of this is a small macro framework to facilitate tree search. But point is taken and I will code some example in schelog to compare. > > 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.] Oh, hmm, to equalize the balance in universe you may call me stefann from now on ;-), > > ;; 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. Yep that is a good point. On the other hand I think that Wright's matchers look nicer on many common patterns than to do the below ritual. > 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. Yep, it's really not a stupid thing to design it this way. > 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. Yeah, cool. But replacing car cdr ... needs a separate code path added letting the symbols used for list processing flow with the pattern compilation process and then one can use the : syntax to define a dispatcher that alters the meaning of the list processing like in the example I made in the previous mail. maybe (: (match-dispatcher1 data1 ...) (match-dispatcher2 data2 ...)) and allow for this pattern only at the top of the match, so by doing (match (:) ...) will be exactly Wrights matcher? /Stefan