From: Aaron Patterson Date: 2011-01-28T07:14:35+09:00 Subject: [ruby-core:34909] Re: [Ruby 1.9-Feature#4326][Open] Fiber should respond to call() and [] --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 27, 2011 at 01:07:33PM +0900, Nobuyoshi Nakada wrote: > Hi, >=20 > At Wed, 26 Jan 2011 16:08:52 +0900, > Aaron Patterson wrote in [ruby-core:34861]: > > Fibers are considered to be coroutines. Knuth says > > "Subroutines are special cases of ... coroutines". This > > makes sense to me. >=20 > Do you mean > "A is kind of B, A has a feature X, therefore B also should > have X", > but not > "A is kind of B, B has a feature X, therefore A also should > have X"? >=20 > Sounds strange to me. Maybe code will be more clear. I want to do this: def square block block.call ** 2 end =20 callables =3D [ lambda { 10 }, Fiber.new { Fiber.yield 10 } ] =20 callables.map { |thing| square thing } Instead I have to do this: def square block value =3D block.is_a?(Fiber) ? block.resume : block.call value ** 2 end =20 callables =3D [ lambda { 10 }, Fiber.new { Fiber.yield 10 } ] =20 callables.map { |thing| square thing } --=20 Aaron Patterson http://tenderlovemaking.com/ --2oS5YaxWCcQjTEyO Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJNQe44AAoJEJUxcLy0/6/GKrMH/RJ03njRzY89+pveJtM/VvLi b98tHTHB92xRjjjSnVb7HV8tcDgfFLMeWcReHaLHGPNGG/mnAmdJN/DRJS9GrhZn LTGa5fLu7KWBaXumEKWLfjkc9BkQXyMkHCHVckG94SuuR+4yPSJAqaLX2bVS1txO whF0aKSM9tZ9F1JstEAjwEJyZqbm9KSVfjDO8PxkUVppZCUojCMYqajIESsQizcL BWoYQEw0YUS3oMXDhbrnS5Q5YL5WyALED1mMAuJETpbk54dUdUU9HaUF2S1DoVlr uiTjLT5ax85KBmiLtvvrBPAGqWbKtcZqJBADo7nSSujQ9la6o5xUK0A93hoVHH8= =MKh5 -----END PGP SIGNATURE----- --2oS5YaxWCcQjTEyO--