Generator vs Coroutine - What's the difference?
generator | coroutine | Hyponyms |
One who, or that which, generates, begets, causes, or produces.
# (chemistry) An apparatus in which vapour or gas is formed from a liquid or solid by means of heat or chemical process, as a steam boiler, gas retort etc.
# (music) The principal sound or sounds by which others are produced; the fundamental note or root of the common chord; -- see also generating tone.
# (mathematics) An element of a group that is used in the presentation of the group: one of the elements from which the others can be inferred with the given relators.
# (geometry) One of the lines of a ruled surface; more generally, an element of some family of linear spaces.
# (programming) A subordinate piece of code which, given some initial parameters will generate multiple output values on request.
A piece of apparatus, equipment, etc, to convert or change energy from one form to another.
# Especially, a machine that converts mechanical energy into electrical energy.
(programming) A piece of code that performs a task, and that can be passed new input and return output more than once.
Coroutine is a hyponym of generator.
In programming terms the difference between generator and coroutine
is that generator is a subordinate piece of code which, given some initial parameters will generate multiple output values on request while coroutine is a piece of code that performs a task, and that can be passed new input and return output more than once.As nouns the difference between generator and coroutine
is that generator is one who, or that which, generates, begets, causes, or produces while coroutine is a piece of code that performs a task, and that can be passed new input and return output more than once.generator
English
Noun
(en noun)Antonyms
* (one which generates) extinguishercoroutine
English
Alternative forms
* co-routineNoun
(en noun)- Although a powerful tool, coroutines can be hard to understand due to the way data can flow back and forth between sections of the code.