3 ms·
Perhaps this is why so many people are confused by the multiple uses of "yield" in programming. For example, in a generator context, the metaphor is that the g
by jayferd 14y ago
Perhaps this is why so many people are confused by the multiple uses of "yield" in programming. For example, in a generator context, the metaphor is that the generator yields (produces) an element. In a threading context, a thread yields (concedes) to other threads.
- syncopatience 14y agoThanks for this. I've always been a little perplexed as to why an enumerator in Ruby uses 'yield' when it seemed like it was really the caller that was "yielding" to the enumerator. I ought to have been thinking of an enumerator yielding (as in giving) a value to the block provided by the caller.
- jules 14y agoActually, this is why yield is such an excellent word. If you yield X from a generator, that does two things: 1. Produce the value X from the generator. 2. Yield execution to the calling context. i.e. exactly the two meanings of yield.
- danielweber 14y agoIt's only because we couldn't find yet another use for "static".