Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Continuations: Ye or Nay?

Name: Anonymous 2014-08-30 1:45

This is what your Scheme compiler/interpreter does to everything you write just to support call/cc which most people rarely use. This is why some Schemes don't implement them.

http://en.wikipedia.org/wiki/Continuation-passing_style

; Your code
(define (pyth x y)
(sqrt (+ (* x x) (* y y))))

; Your Scheme repl shitting out your code
(define (pyth& x y k)
(*& x x (lambda (x2)
(*& y y (lambda (y2)
(+& x2 y2 (lambda (x2py2)
(sqrt& x2py2 k))))))))

Name: Anonymous 2014-08-31 21:13

>>6
Sure you can, you still do the CPS transformation into tail calls, but then you inline everything and don't bother with allocating GC frames to capture the continuation and arguments.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List