Re:Auto-antonym
by jayferd on Thursday January 10, 2013 @01:07PM
(#5038576)
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.
[ Parent
| on HN ]
Actually, 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.
Re:Auto-antonym
by syncopatience on Thursday January 10, 2013 @02:10PM
(#5039032)
Thanks 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.
Re:Auto-antonym
by danielweber on Thursday January 10, 2013 @03:41PM
(#5039605)
It's only because we couldn't find yet another use for "static".