Help needed with the CPS transform involving py-list*

26 views
Skip to first unread message

Jeremy Mefford

unread,
Apr 11, 2013, 9:55:47 PM4/11/13
to utah-compiler...@googlegroups.com
Okay, so i'll be honest that I don't fundamentally understand the CPS thing very well yet.  My implementation thus far is a mix of Matt's code from blog posts as well as my own makeup.  I am taking the hybrid CPS approach.  However I am experiencing to me what seems very strange behavior even with the reference implementation.  Take for instance the following two examples (I realize they are not valid according to cps-header):

(program
    ((λ () (lambda1))
     (void2)
     (λ () (arg2))))

CPS output

(program
 (void2
  (lambda (rv17)
    ((lambda (k16) (lambda1 k16)) rv17 (lambda (k18) (arg2 k18)) $halt))))

-----------------------------

(program
    ((λ () (lambda1))
     (py-list* 1 2 3)
     (λ () (arg2))))

CPS Output

(program
 ((lambda (k16) (lambda1 k16))
  (py-list* 1 2 3)
  (lambda (k17) (arg2 k17))
  $halt))

How come in the first example the void2 is moved up as the primary function with the immediate lambda passed in as the continuation and in the second example the order of the lambda in reference to the pylist is preserved?  How come (void2) behaves differently than (py-list* 1 2 3)?  What am I missing here?
Reply all
Reply to author
Forward
0 new messages