guile-user
[Top][All Lists]
Advanced

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

minimal CPS program?


From: Matt Wette
Subject: minimal CPS program?
Date: Mon, 21 May 2018 20:25:43 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Hi All,

I'm trying to compile a minimal cps program.   Can anyone provide this?

Here is what I have

(define (doit)
  (parameterize ((label-counter 0)
                 (var-counter 0))
    (with-cps empty-intmap
      (letv init)
      (letk kinit ,#f)
      (letk ktail ($ktail))
      (letk kbody ($kargs () () ($continue ktail #f ($const 1))))
      (letk kclause ($kclause ('() '() #f '() #f) kbody #f))
      ($ ((lambda (cps)
            (let ((init (build-cont ($kfun #f '() init ktail kclause))))
              (with-cps (persistent-intmap (intmap-replace! cps kinit init))
                kinit))))))))

(compile (doit) #:from 'cps #:to 'bytecode)

which generates

language/cps/types.scm:1646:7: In procedure visit-cont:
Throw to key `match-error' with args `("match" "no matching pattern" #<cps 
(ktail)>)'.

The cps (intmap) is

(0 . #<cps (kfun () 0 1 3)>)
(1 . #<cps (ktail)>)
(2 . #<cps (kargs () () (continue 1 (const 1)))>)
(3 . #<cps (kclause (() () #f () #f) 2)>)





reply via email to

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