44
submitted 1 year ago by runiq@feddit.de to c/rust@programming.dev

What is this title

top 11 comments
sorted by: hot top controversial new old
[-] anlumo@feddit.de 4 points 1 year ago

The section titled “what is the difference” doesn’t explain what the difference is, only what a generator is (which I already knew).

[-] sugar_in_your_tea@sh.itjust.works 2 points 1 year ago* (last edited 1 year ago)

It's essentially a name change.

The two concepts are very similar, with the main difference being coroutines can receive arguments after invocation and generators generally cannot (here's a good explanation if you want to get more into it). Here's a write up about Rust's implementation, they're more than generators and from reading over it they may allow passing data in with each resume (I haven't played with them in Rust, but I've used the concept a lot in Lua, Python, and Go).

Then again, like the second link says, the boundaries of both can vary conversation to conversation. Python generators, for example, can also be used as coroutines (see this PEP).

[-] m_e@lemmy.ml 3 points 1 year ago

The only language to get it right was Simula 67.

[-] davawen@programming.dev 8 points 1 year ago

Could you explain to me how simula's implementation of coroutines differ from modern languages (be it stackless or stackful)? I tried to dig a little but didn't find much and I don't really have time to investigate further.

Thank you!

[-] m_e@lemmy.ml 1 points 11 months ago

Simulation 67 keeps the coroutine data on the heap (it is garbage collected).

this post was submitted on 24 Oct 2023
44 points (97.8% liked)

Rust

5974 readers
56 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS