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-i>
   (<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