Generator syntax (Re: FW: FW: [Python-Dev] Simple generator implementation)

Neil Hodgson nhodgson@bigpond.net.au
Thu, 22 Mar 2001 13:14:22 +1100


Jeremy Hylton:

> On the subject of keyword preferences, I like yield best because I
> first saw iterators (Icon's generators) in CLU and CLU uses yield.

   For me the benefit of "yield" is that it connotes both transfer of value
and transfer of control, just like "return", while "suspend" only connotes
transfer of control.

   "This tree yields 20 Kilos of fruit each year" and "When merging, yield
to the vehicles to your right".

   Neil