[Top][All Lists]

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

Delimeted continuations for gule-log guile-prolog and kanren

From: Stefan Israelsson Tampe
Subject: Delimeted continuations for gule-log guile-prolog and kanren
Date: Sat, 5 Oct 2013 20:24:31 +0200

Hi all,

Delimited continuations are a really nice feature in guile. I have now implemented that
for guile-log and hence also for kanren and prolog. With it we can now do
(use-modules (logic guile-log))
(use-modules (logic guile-log umatch))

(<define> (f)
  (<values> (i x) (<abort> 'tag (<lambda> (i x) (<cc> i x))))  
   (<or> (<=> x i)      (<=> x ,(+ i i)))
   (<or> (<=> x ,(- i)) (<=> x ,(- (+ i i))))))

(<define> (test x y)
  (<prompt> 'tag #f f
    (<lambda> (tag next kk)
        (<let> ((k (kk)))
  (<zip> (x (k 1  x))
 (y (k 10 y)))))))

(<run> 10 (x y) (test x y))

--> $1 = ((1 10) (-1 -10) (2 20) (-2 -20))

This shows delimited continuations works in combination with interleaving and zip constructs
(zip evaluates all it's argumets in parallell). And I claim that the continuation is first class and can be used soundly everywhere above the <prompt> construct. I documented it in the guile-log manual for anyone interested in using this. To note is that this constructs is first class and should work quite well with all features of guile-log e.g. It will work well with zip like constructs, interleaving construct, postpone, storing and restarting and all accumulator constructs. Also it is really efficient in many ways and contains optimization for handling breath first search with storing a huge number of continuation points in e.g. the postpone construct.

There is published paper from this year about non first class continuations in prolog ontop WAM.

Probably guile-log should be documented and published as a scientific paper, anybody interested in mentoring such an effort?

I will continue with implementing iso-prolog next and then do a release.

Happy Hacking

reply via email to

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