Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
syntax for guaranteed coroutine frame allocation elision #1260
It's certainly possible to make a runtime safety check for this. We can make a convention that passing a null pointer as the allocator means it must be elided, and then when asked to do an allocation, if the allocator is null, call panic.
Theoretically we should be able to have a compile error for not being able to do the elision. However this depends on LLVM IR passes. So it would require inspection into the LLVM IR module post-optimization. This is inherently tricky and would require research.
referenced this issue
Jul 18, 2018
With error handling:
Here's the above example but using the
When we solve #157, this recursive function would be a compile error:
This is solved with stackless functions (aka coroutines aka async functions):
Calls to this function grow heap memory, not stack memory. The function can return