Skip to content

Conversation

@Simn
Copy link
Member

@Simn Simn commented Dec 30, 2025

The time has come.

Simn and others added 30 commits April 17, 2025 09:11
# Conflicts:
#	src/context/typecore.ml
#	src/typing/typeloadCheck.ml
#	src/typing/typeloadFields.ml
#	src/typing/typer.ml
* try php

* and lua
* make coros exception-free

* avoid double looping if there's no catch

* add more exception tests

* add test for nested try-catch

* try to get exce[topm value management right

* port remaining YieldTryCatch cases

* make nested test even crazier

* change throw to break to avoid inner exceptions

* fix indentation

* also test throw from child coro

* ignore some tests on lua because there's a codegen issue

* lua isn't ready for this

* try again

* Move recursion tests back to flow control suite

* Fix missing import

---------

Co-authored-by: Aidan Lee <aidan.lee63@gmail.com>
* make coros exception-free

* avoid double looping if there's no catch

* add more exception tests

* add test for nested try-catch

* try to get exce[topm value management right

* port remaining YieldTryCatch cases

* make nested test even crazier

* change throw to break to avoid inner exceptions

* fix indentation

* also test throw from child coro

* ignore some tests on lua because there's a codegen issue

* lua isn't ready for this

* try again

* it works I guess

* also add to BlockingContinuation to lose the casts

* run JVM tests through hxb roundtrip

* be more accurate

* deal with LocalFunc type paramters too

* use more precise type on suspend

* T for all
The reason I prefer this is because it prevents us from accidentally messing up the order.
* optimize

* another flag

* add missing catch handling, enable reindexing

* remove inner recursion from texpr transformer

* move functions to where they should be
@Simn
Copy link
Member Author

Simn commented Dec 31, 2025

There are still various issues to sort out but the whole thing is going to be in experimental state for a while anyway, plus I kind of promised that we would get coroutines in 2025, so let's just do it!

@Simn Simn merged commit b621f2b into development Dec 31, 2025
97 checks passed
@back2dos
Copy link
Member

Congrats to finally getting this done ;)

I have heaps of questions, but I'll just stick to those I can articulate properly:

  1. Are there some "docs" about this? I see some tests and inline docs and suppose a lot can be figured out from there. But undoubtedly a lot of thoughts went into this and it would be great to understand some of them. Perhaps just slap the chat history into an LLM and ask it to summarize :D
  2. What's the idea behind the hxcoro haxelib? Are implementations of Scheduler intended to happen in user land? Or is it simply to be able to iterate the runtime(s) faster than the compiler?
  3. Totally random minor nitpick: Instead of Int64, might it not be better to use the Int53 proposed elsewhere?

@Simn
Copy link
Member Author

Simn commented Dec 31, 2025

Thank you for your interest in our product!

  1. Most of the public types and functions should at least have some documentation by now, but there's definitely more work to do in that area. I've started some general documentation over at https://github.com/HaxeFoundation/hxcoro/wiki/Hello-Coro which will see updates in the coming days.
  2. We follow Kotlin in this regard by having only the parts that the compiler actually needs in std, while most of the functionality is in the hxcoro lib. So while Haxe roughly knows what a scheduler is (because continuations need that), how exactly it is implemented is not its concern. This allows us to update most things related to coroutines without updating the compiler.
  3. We went with Int64 because by now it has good support on most targets, so it seemed like the obvious choice. This could be changed later if that becomes necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants