2

I realize that Clojure specifically chose to not have continuations.

I am currently playing with ClojureScript.

I notice that in JavaScript's AJAX call protocol, I often pass a function to handle "what to do after the AJAX call returns."

This sounds very much like a continuation.

Is there some standard way to setup CPS in ClojureScript?

If not, what is the right way to handle AJAX call backs?

Thanks!

2 Answers 2

2

Clojure (and ClojureScript) lack first-class continuations, unlike Scheme, but there's nothing stopping you from writing code in explicit continuation-passing-style. You're right, a JavaScript AJAX call that takes a function callback is similar.

Check out this other question on SO for AJAX and ClojureScript, which points out how to use the Google Closure library, and is probably the easiest to start with "out-of-the-box".

Sign up to request clarification or add additional context in comments.

Comments

0

You might want to check out Ganelon microframework for Clojure (which I am author of).

There are no CPS there, but the general idea - that server-side AJAX callbacks can update client-side contents or execute client-side JavaScript is quite similiar to continuation-style web framework for Common Lisp - Weblocks.

Demo & docs for Ganelon are available at http://ganelon.tomeklipski.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.