scheme - How to implement call-with-values to match the values example in R5RS -


r5rs says...

values might defined follows:

(define (values . things)   (call-with-current-continuation     (lambda (cont) (apply cont things)))) 

it doesn’t, however, how call-with-values might implemented if values implemented way. so, if values implemented way, how call-with-values implemented?

(this came because trying code used call-with-values work tinyscheme, doesn’t support it. managed faking values , call-with-values lists, but—when saw in r5rs—i wanted know if might better workaround.)

the short answer is: can't

the nifty implementation of values not change fact there no way implement other procedures if don't have of them poke @ values. if had 1 way peek implement others that.

(+ (values 4 5)) (apply + (values 4 5)) 

doesn't work , that's why need other primitives.

when said. there no difference between returning more values , returning lists values since difference optimization. make macro treats both of them binding , way use them same. difference in performance pointer jumping , consing reasonable fast lisp implementation. heres minimalistic implementation work given code correct:

(define values list) (define (call-with-values producer consumer)   (apply consumer (producer))) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -