Ruby Impressions

Tim Peters tim.one at home.com
Fri Jan 11 04:20:35 EST 2002


[Phil Tomson]
> ...
> Now that Python 2.2 has a 'yield' operator (like Ruby had from the
> start)

The word, but not the semantics.  Python's yield is named after CLU's yield,
and acts very much like it; although a more direct influence was Icon's
generators, where the Python yield acts much like Icon's suspend.  The Ruby
yield would baffle anyone coming from CLU or Icon -- it's more Smalltalkish,
implicitly executing a parameterized closure passed to the procedure
containing the yield.  For a clear example of the difference in practice,
see "5.5 How can I run iterators in parallel?" ["lockstep" would be a more
accurate phrasing] in the Ruby FAQ.  It's easier in Python (but not in CLU
or Icon either!) -- no threads needed, as it's natural for a Python
generator to yield one result at a time, and generators are first-class
objects that can be explicitly resumed at will independent of magical
control context.

> and now that Python is trying to unify their type/class system so
> that you'll be able to inherit from builtin types (like Ruby has been
> able to from day  one)... are we to conclude that Python 2.2 is just a
> bad ripoff of Ruby?

If it pleases you, sure <wink>.

> Like I said, I couldn't resist (as he puts his flame proof suit on ;-)
>
> No ill will intended.  It's primarily a case of 'different strokes for
> different folks'.

No, it's Good versus Evil, and the Evil Ones must die.  At least on Usenet.

mentioning-hitler-at-the-start-to-cut-it-off-short-ly y'rs  - tim





More information about the Python-list mailing list