3 ms·
Return terminates the function or thread of execution. Yield (may) provides a value but leaves the thread of execution alone otherwise, only pausing it. It’s re
by Jtsummers 5y ago
Return terminates the function or thread of execution. Yield (may) provides a value but leaves the thread of execution alone otherwise, only pausing it. It’s resumable where a return is not (without a lot of extra bookkeeping).
https://blog.golang.org/waza-talk https://blog.golang.org/waza-talk
A good talk that expresses the current sentiment and helped establish it. Concurrency may be parallel, but doesn’t need to be. This does go against the common (outside programming) notion of the meaning of concurrent which means it provides a strong potential for confusion.
- gpderetta 5y agoEquivalently, both yield and return invoke the calling function continuation, but while return discards the current one, yield saves it somewhere for resumption.