From: "Shot (Piotr Szotkowski)" Date: 2009-10-10T09:08:14+09:00 Subject: Re: Backporting Enumerator.new { ... } to Ruby 1.8.7 --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Roger Pack: >> Unfortunately, my code heavily uses lazy-evaluated, nested Enumerator >> objects. What is the sanest way to backport the following example >> so that it works more-or-less in the same way under Ruby 1.8.7 as >> it does under Ruby 1.9? > looks like there's a couple ways > one > require 'backports' > # leave the original code as is Oh, wow! How could I have missed this? (Does not show up on =E2=80=98Ruby backporting=E2=80=99 Google queries, but still=E2=80=A6) This plus some ama= zingly minimal monkey-patching got me a backport in two hours or so. :) > or this one > require 'generator' > def multiplier param > Generator.new do |yielder| =E2=80=A6AND I have missed Ruby 1.8=E2=80=99s stdlib=E2=80=99s Generator! A= double shame, but I=E2=80=99m happy as a clam nevertheless =E2=80=93 I=E2=80=99ll finally= be able to nicely profile my PhD code! (Even if the results do not necessarily reflect Ruby 1.9=E2=80=99s bottlene= cks, I guess they will be close enough, and being able to profile my code will most probably turn the rest of the month into a very interesting adventure with RuDy=C2=B9.) =C2=B9 http://app.euruko2009.org/talks/21-announcing-rudy-write-ruby-native= -extensions-in-d-programming-language Thanks again, Roger, I can=E2=80=99t say enough how happy I am with the abo= ve. =E2=80=94 Shot --=20 Idea: A James Cameron-directed prequel entitled =E2=80=98T\0: The Null Terminator=E2=80=99. [Matthew Baldwin] --4Ckj6UjgE2iN1+kY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkrP0GkACgkQi/mCfdEo8UqZFwCgoHgH40p3f1qAjW73+rqwImQ5 9cgAn3qo+GIcNEZwgz1xEVVkfPpkY1EJ =FffO -----END PGP SIGNATURE----- --4Ckj6UjgE2iN1+kY--