Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement continuations #1

Open
scribu opened this issue Apr 13, 2013 · 1 comment
Open

Implement continuations #1

scribu opened this issue Apr 13, 2013 · 1 comment

Comments

@scribu
Copy link
Owner

scribu commented Apr 13, 2013

  (call-with-current-continuation
    (lambda (return)
      (begin
        (display "One ")
        (return #t)
        (display "Two ")
        #f)))

The lambda-expression evaluates to an anonymous function of one parameter. This anonymous function gets invoked by call-with-current-continuation and the parameter - here called return - gets bound to an escape procedure, i.e. a procedure value that encapsulates the current continuation. The function prints "One " and then returns #t without ever printing "Two " because the second display-expression is part of the abandoned continuation.

http://c2.com/cgi/wiki?CallWithCurrentContinuation

@scribu
Copy link
Owner Author

scribu commented Apr 13, 2013

Implementation wise, it should just be a matter of storing a reference to the parent subtree and then re-evaluating it after (return) is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant