News for hackers. Stuff that matters.
Re:Racket is 25 by sweeneyrod on Sunday May 10, 2020 @03:27PM (#23135356)
Who uses CPS in daily programming? Or do you mean using a compiler that uses it?
Re:Racket is 25 by Twisol on Sunday May 10, 2020 @04:03PM (#23135670)
The Visitor pattern is not much more than a CPS-style transform that lets you represent sum types in a language without them.

A CPS transform for a computation of type `X` gives a computation of type `forall A. (X -> A) -> A`. That is, instead of evaluating to ("returning") a value of type `X`, you take a function that you deliver a valid of type `X` to, and return whatever it returns.

CPS-transforming a sum type `X + Y` gives `forall A. (X + Y -> A) -> A`, and if you distribute over the sum you get `forall A. ((X -> A) * (Y -> A)) -> A`. The visitor is the pair of functions you pass in, `(X -> A) * (Y -> A)`, and the value decides which method to call. In either event, it returns whatever the chosen visitor method returns.

(Dropping into Java syntax, this is the type of the `visit` method: `<A> A visit(Visitor<A> visitor)` -- and the Visitor is `interface Visitor<A> { A onX(X x); A onY(Y y); }`.)

Re:Racket is 25 by agumonkey on Sunday May 10, 2020 @10:20PM (#23138283)
I cannot claim it is, but async/await, at least in ES seems to be a continuation monad without the do notation.
Re:Racket is 25 by skrishnamurthi on Sunday May 10, 2020 @04:50PM (#23136044)
Callback hell in JavaScript.
Re:Racket is 25 by hintymad on Sunday May 10, 2020 @04:06PM (#23135704)
Definitely in compiler, but also in daily JavaScript as a way to avoid deeply nested callbacks.
Re:Racket is 25 by emsal on Sunday May 10, 2020 @07:53PM (#23137427)
I'm no expert but I think that the async-await pattern is quite similar to CPS.