On Tue, Mar 24, 2009 at 8:35 PM, P.J. Eby <p...@telecommunity.com> wrote: > Now, if somebody came up with a different way to spell the extra value > return, I wouldn't object as much to that part. I can just see people > inadvertently writing 'return x' as a shortcut for 'yield x; return', and > then having what seem like mysterious off-by-one errors, or being confused > by receiving a generator object instead of their desired non-generator > return value. > > It also seems weird that the only syntactically-supported way to get the > generator's "return value" is to access it inside *another* generator... > which *also* can't return the return value to anyone! > > But if it were spelled 'raise Return(value)' or 'raise StopIteration(value)' > or something similar (or even had its own syntax!), I wouldn't object, as it > would then be obvious how to get the value, and there could be no possible > confusion with a regular return value. > > The unusual spelling would also signal that something unusual (i.e., > multitasking) is taking place, similar to the way some frameworks use things > like 'yield Return(value)' to signal the end of a task and its return value, > in place of a value in the stream.
I'm sympathetic to this point of view. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com