guile-user
[Top][All Lists]
Advanced

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

Re: CPS mystery


From: Matt Wette
Subject: Re: CPS mystery
Date: Tue, 29 May 2018 19:58:06 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 05/29/2018 10:54 AM, Mark H Weaver wrote:

Hi Matt,

The problem here is that 'resolve' returns a variable object, but 'call'
expects a procedure.  So, you need another continuation between
continuations 6 and 5 above, which does (primcall box-ref <>) to extract
the procedure from the variable object.

Also, I believe the (values 1) in continuation 2 above is incorrect.  It
expects its argument to be a list, whereas in this case it would be a
number.  It's not needed here.

Thanks.  I got it working!

calc@(guile-user)> 1 + 2
(program
  (expr-stmt (add (fixed "1") (fixed "2"))))
(0 . #<cps (kfun () 0 1 9)>)
(1 . #<cps (ktail)>)
(2 . #<cps (kargs (arg) (4) (continue 1 (call 2 3 4)))>
(3 . #<cps (kargs (arg) (3) (continue 2 (const 2)))>)
(4 . #<cps (kargs (arg) (2) (continue 3 (const 1)))>)
(5 . #<cps (kargs (bx) (5) (continue 4 (primcall box-ref 5)))>)
(6 . #<cps (kargs (t) (7) (continue 5 (primcall resolve 6 7)))>)
(7 . #<cps (kargs (name) (6) (continue 6 (const #t)))>)
(8 . #<cps (kargs () () (continue 7 (const +)))>)
(9 . #<cps (kclause (() () #f () #f) 8)>)
$1 = 3




reply via email to

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