I've just released my moon-core library. It's been around for a long time, but I've finally open sourced it after removing some nda related stuff. moon-core has a number of stuff like BigInteger, random number generation algorithms, templating and routing, and other stuff. Basically the common stuff from various work projects gets dumped into moon-core.
Anyway, I've recently implemented a feature I've been longing for in haxe, which is the yield expression, so we can write readable asynchronous code. It behaves like the yield keyword in JavaScript, Python, and C#. So long as there's a @yield within a function, that function will be transformed into a resumable function. It allows you to easily write iterators.
After having generator functions, we can also now have fibers, an alternative to threads. Fibers use cooperative-multitasking, while threads use preemptive-multitasking. The yield expressions will be where the fiber takes a break and lets the next fiber resume running.
On single-threaded environments, this can be useful if you need to have long running codes and expensive computations without locking up the UI.
The async macro implementation is not perfect, and there's still some issues that needs to be solved. For example, I'm totally clueless on how make try/catch work. For other simple usage, it works okay.
Check it out here:
If you're wondering how it works, this gist shows the different transformation passes for a fibonacci function:
It's also on haxelib as moon-core
Contributions are welcomed, and I hope someone finds this useful!