JuliaDynamics / ResumableFunctions.jl

C# style generators a.k.a. semi-coroutines for Julia.
Other
160 stars 19 forks source link

Add support for delegation and return values with @yieldfrom #57

Closed gerlero closed 1 year ago

gerlero commented 1 year ago

This is a basic implementation of delegation to a subgenerator inspired by PEP 380. Delegation with a plain @yieldfrom iter expression (i.e., no assignment on the left) should work for any iterable, while arg = @yieldfrom f requires that f is actually a @resumable function, as I didn't find a standard mechanism for iterators to "return" values. Note that in the latter case, arg will be assigned the return value of f: this also means that it now makes sense for a @resumable function to also return a value, so I've removed the warning for this case.

Closes #49

EDITS: @yield_from -> @yieldfrom (https://github.com/QuantumSavory/Semicoroutines.jl/pull/8), typo

Krastanov commented 1 year ago

I believe Ben, the original author, might not have the bandwidth to work on ResumableFunctions these days. Thus, I forked the repository into a new Semicoroutines.jl https://github.com/QuantumSavory/Semicoroutines.jl in order to support 1.10 and future julia versions.

@gerlero , could you consider making this pull request against the fork?

As this library is an important part of another project of mine, I plan to provide support at least for the next few years. I am certainly interested in having help from other contributors (and maybe merging things back here if ResumableFunctions.jl is revided).

A similar fork is being prepared for SimJulia

gerlero commented 1 year ago

Sure enough. Thanks! I'll open the same PR against Semicoroutines.jl

BenLauwens commented 1 year ago

Please resolve conflicts so that this can be merged.

gerlero commented 1 year ago

@BenLauwens The same PR is currently open against Semicoroutines.jl (at https://github.com/QuantumSavory/Semicoroutines.jl/pull/8). If possible, I'd prefer to wait for that one to be merged there, to ensure both packages remain compatible.

Krastanov commented 1 year ago

@gerlero , give me a few hours to fix the tests, so we have JET and Aqua available. That might also already fix most of the merge conflicts.

gerlero commented 1 year ago

@Krastanov Let me know when I can start working on the merge conflicts for this one.

Krastanov commented 1 year ago

Please go ahead! Tests and CI are already updated.

Krastanov commented 1 year ago

I guess we need to decide whether to drop support for Julia 1.2... The current LTS is 1.6, anything older is not really supported upstream either.

hdavid16 commented 1 year ago

I support dropping it. I would go with LTS and up.

gerlero commented 1 year ago

I couldn't easily figure out why that error occurs in Julia 1.2, and don't believe any additional effort would be really worth it with that Julia version. I'd be fine with dropping support for anything older than 1.6 LTS.

Krastanov commented 1 year ago

Let's wait until next week when we will have a more extended discussion with Ben and bring it up then. I am also in favor of dropping pre-1.6 versions.

Krastanov commented 1 year ago

In the meantime could you go ahead and modify the project.toml (to increase to julia 1.6 and to bump the version number for the package) and add a quick description to README in the change log section?

gerlero commented 1 year ago

In the meantime could you go ahead and modify the project.toml (to increase to julia 1.6 and to bump the version number for the package) and add a quick description to README in the change log section?

Done. I've bumped just the patch component (to v0.6.3), pending/following discussion at #63, but it's up to you and others if you think this should get a different version number (e.g. 0.7 or 1.0).

Krastanov commented 1 year ago

all the cleanup from the move is now finished, so I am merging this. Thanks for the contribution!!!

gerlero commented 1 year ago

@Krastanov thank you!