ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

Enhancement: Async via Computation Expressions #1273

Open peter-schwier opened 9 years ago

peter-schwier commented 9 years ago

I'm not sure if you are working on Async at the moment or not. I though I would put this forward as a possibility.

F# has a way of defining Async expressions within the language using a feature called Computation Expressions. (https://msdn.microsoft.com/en-us/library/dd233182.aspx) What happens is that at compile time the synchronous code that you have written is transformed into a bunch of functions called by some control functions.

A side effect of this is that if Async is implemented differently in different platforms (which it is different between node.js, the browser, and vert.x) then the differing implementations can be safely written in Ceylon.

At this point writing synchronous code that works as async is the one feature I am waiting on to start using Ceylon for writing some web apps. Yes, I know I can use promises and callbacks. That does not work well with try...catch blocks or with try(resource) blocks. Using Computation Expressions the try...catch support for async can be built into the language.

gavinking commented 9 years ago

Peter I will take a look.

Sent from my iPhone

On 11 Apr 2015, at 2:11 pm, Peter Schwier notifications@github.com wrote:

I'm not sure if you are working on Async at the moment or not. I though I would put this forward as a possibility.

F# has a way of defining Async expressions within the language using a feature called Computation Expressions. (https://msdn.microsoft.com/en-us/library/dd233182.aspx) What happens is that at compile time the synchronous code that you have written is transformed into a bunch of functions called by some control functions.

A side effect of this is that if Async is implemented differently in different platforms (which it is different between node.js, the browser, and vert.x) then the differing implementations can be safely written in Ceylon.

At this point writing synchronous code that works as async is the one feature I am waiting on to start using Ceylon for writing some web apps. Yes, I know I can use promises and callbacks. That does not work well with try...catch blocks or with try(resource) blocks. Using Computation Expressions the try...catch support for async can be built into the language.

— Reply to this email directly or view it on GitHub.