WIP: call-with-values

This commit is contained in:
Justin Ethier 2015-06-04 22:37:32 -04:00
parent 5c82cd7aef
commit ab48faaa5e
2 changed files with 12 additions and 6 deletions

View file

@ -133,18 +133,23 @@
(set! globals (cons 'call/cc globals))
(set! module-globals (cons 'call/cc module-globals))
(set! input-program
;(cons
; '(define call-with-values
; (lambda (k producer consumer)
; (producer
; )
(cons
;; Experimental version of call-with-values, but this
;; is not working yet!
'(define call-with-values
(lambda (k producer consumer)
(producer
(lambda (val)
(consumer k val)))))
;(lambda vals
; (apply k consumer vals)))))
(cons
;; call/cc must be written in CPS form, so it is added here
;; TODO: prevents this from being optimized-out
;; TODO: will this cause issues if another var is assigned to call/cc?
'(define call/cc
(lambda (k f) (f k (lambda (_ result) (k result)))))
cps)));)
cps))))
(else
;; No need for call/cc yet
(set! input-program cps))))

View file

@ -6,6 +6,7 @@
;delete-duplicates
call-with-current-continuation
call/cc
call-with-values
values
;(Cyc-bin-op cmp x lst)
;(Cyc-bin-op-char cmp c cs)