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

View file

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