JuliaDynamics / ResumableFunctions.jl

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

`@yield` if used outside a `@resumable` should throw an error #10

Closed oxinabox closed 6 years ago

oxinabox commented 6 years ago

First: thank you so much for this, I am so excited. I've missed these for years. In 0.5 I was using Tasks but they are unperforment and a bit weird. In 0.6 that is deprecated.

Currently the (documented and actual) behavour of @yield outside a @resumable is to be converted into :(nothing). I suggest it should throw an error. You can throw errors during macro creation (not just return (:(throw(Error(....))), but actually throw them. It will cause an error at compile time, rather than runtime (which is great).

It is almost certainly a programmer error to use a @yield outside of an @resumable, and as the programmer I want to know about that error ASAP.

(this would be a breaking change)

BenLauwens commented 6 years ago

It feels good to hear that I am not the only one using this package;) This is indeed a very good idea. I have just implemented it and pushed it to the master branch. Can you check that this is the behaviour you wanted?

oxinabox commented 6 years ago

Seems good to me

BenLauwens commented 6 years ago

I have just released a new version. Once METADATA.jl is updated I will close the issue.