Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yielding api #595

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

yielding api #595

wants to merge 2 commits into from

Conversation

devsnek
Copy link
Contributor

@devsnek devsnek commented Feb 29, 2024

something i'm experimenting with in devsnek/jsont#1

@filmor
Copy link
Member

filmor commented Jul 7, 2024

Are you still working on this or did you hit a roadblock? I'd be interested in exploring a high-level variant of this using Rust's async functions.

@devsnek
Copy link
Contributor Author

devsnek commented Jul 7, 2024

I no longer work at the company where I was working on this. Async functions would be cool and I experimented with it a bit. The main issue is that it's difficult to provide an Env to async functions correctly. I tried some hacks like a fake env that implements deref to get the real env but I'm fairly sure it's not actually possible in safe rust to prevent the reference from being held across await points. It is doable in generators though, and I at one point had something working where env references are passed in via yield. the only annoyance with this is that you still can't hold any values across suspend points, you need to somehow interface with rust and put all the values it captures into the reschedule arguments and that's not possible. So I ended up with the much simpler model you see here.

@filmor
Copy link
Member

filmor commented Aug 30, 2024

The only safe way is to copy all terms to a process-independent environment and use the terms from that one. But that should actually work across awaits, right?

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.

2 participants