On 06/08/13 10:01, Walter Prins wrote:

        py> def cr():  # Co-Routine.
        ...     x = yield()
        ...     while True:
        ...             x = yield(x + 1)
        ...

"send" and yield as akin to threaded execution, where cr() is like a
thread that blocks at the yield call after creation, and then when you
call on magic.send() the "thread" wakes up and continues and eventually
returns another value

It's clever but I'm not keen on it overloading yield to do it.
yield as a word conveys (to me at least) the idea of returning a value but not quite completely ending. This usage sounds like a different concept and I'd have preferred a more explicit name - although I can't think what!! Also I'm not keen on the argument/parameter mechanism here either. Arguments are sent but not explicitly declared in the receiver, that all feels rather un-pythonic to me. But I've only
skimmed it so far, I need to do some hands-on playing I think.

I am getting concerned that python is developing a lot of these
non-intuitive type features, almost because it can(*). A lot of it no doubt scratches somebody's itch but its at the expense of making what was a very easy to use language ever more complex. I'm not sure if i would choose Python for my Learn to Program tutorial if I was starting it these days - although I'm not sure what else is any better...

(*)The same thing happened with C++ between v2 and ISO
standardization - a lot of bells n' whistles were added which made C++ much more complex than was good for it (or for me as a programmer!). Eventually you had to be a guru level coder to use it successfully. Python hasn't got that far yet but it seems to be in danger of it.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to