3 ms·
> no commonly used high level language supports the coroutine This might have been the case back in 2000, but these days many languages do support it, includin
by omoikane 3y ago
> no commonly used high level language supports the coroutine
This might have been the case back in 2000, but these days many languages do support it, including C++20, Lua, Python, Ruby, etc.
- perbu 3y agofwiw, Simula67 had coroutines. Not the first to do so, but IIRC it was the first major language to do so.
- esfandia 3y agoPython was created in 1991; I imagine the "yield" keyword appeared either right then or not much later! Also, the refinement at the end of the article: "We arrange an extra function parameter, which is a pointer to a context structure; we declare all our local state, and our coroutine state variable, as elements of that structure." sounds like implementing a closure to me. You make the callee a lambda which would use an outside var/context/state to determine what to do or with what value. Am I understanding this correctly?
- lmm 3y ago> Python was created in 1991; I imagine the "yield" keyword appeared either right then or not much later! Nope. It was introduced 10 years later, as part of PEP 255, released in Python 2.2.
- kragen 3y agoyour note about closures is correct, yes as lmm pointed out, python didn't have generators and yield until 2.2. icon, which tim peters adapted the idea from, had them quite a bit earlier than that, but i think it's reasonable to describe icon as not being a commonly used language, then or now (python's generators are closer syntactically to icon's generators than they are semantically)