gravity icon indicating copy to clipboard operation
gravity copied to clipboard

async and await

Open alexovi opened this issue 7 years ago • 9 comments

Please add async and await into your Reserved Keywords. I have not seen support of async programming in gravity now, but it will be useful once you will want to add it.

BTW I'm glad that you are not trying to invent wheel and that you use standard, well known syntax from the C** world. Looks nice

alexovi avatar Mar 06 '17 20:03 alexovi

Yeah, definitely a must have for me too! C# has this since several years know for example. Gravity is a great project, I love its simplicity and I can imagine that adding a lot of built-in functionalities is not your final purpose ... but async programming is so common today!

aloisdeniel avatar Mar 07 '17 06:03 aloisdeniel

+1 to adding these to reserved words. Also, async programing IMO implies some sort of event loop that main thread can yield to when awaited result is ready. ATM it seems that the only asynchrony you can get is via using fibers, and there is not many things I can see that will benefit from it at this point.

YurySolovyov avatar Apr 09 '17 21:04 YurySolovyov

@YurySolovyov I started to write binding for libuv here: https://github.com/parro-it/gravity/tree/gruv_2/src/optional/gruv

By now, I implemented only some function of the file system API, but the libuv event loop is working fine. I also thought to implement a Promise class to avoid the excessive use of callback with libuv API.

When we'll have Promises, I think that an await/async semantic could be implemented using gravity Fiber class.

parro-it avatar Apr 09 '17 21:04 parro-it

But do you really have to build async await on top of promises or we can use fibers directly?

YurySolovyov avatar Apr 10 '17 06:04 YurySolovyov

YurySolovyov: Just to check, how its going your efforts with libuv ?

felipetesc avatar Jun 14 '18 21:06 felipetesc

I've never said I'm doing anything with libuv

YurySolovyov avatar Jun 15 '18 07:06 YurySolovyov

I was doing it, but stopped working on it. I'm busy with other projects ATM

parro-it avatar Jun 15 '18 10:06 parro-it

My mistake YurySolovyov . Thank you for answering parro-it.

felipetesc avatar Jun 16 '18 04:06 felipetesc

Fwiw: my libuv bindings are here (based on a very similar project with the same roots): https://github.com/perl11/potion/blob/master/lib/aio.c

rurban avatar Aug 10 '18 04:08 rurban