From: Eric Hodel Date: 2003-08-06T16:53:16-07:00 Subject: Re: Why does Ruby have callcc? --V3eawNQxI9TAjvgi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Eric Hodel (drbrain@segment7.net) wrote: > Ben Giddings (ben@thingmagic.com) wrote: >=20 > > Is there some reason that Continuation.new couldn't work? >=20 > I don't know if this is 100% correct: >=20 > class Continuation > def self.new > if block_given? then > callcc { |c| yield(c) } > else > callcc { |c| return c } > end > end > end Oh yes, and there is this problem: irb(main):007:0> c =3D Continuation.new; puts 'hi' hi =3D> nil irb(main):008:0> c.call hi =3D> nil irb(main):009:0> c.call NoMethodError: undefined method `call' for nil from (irb):9 Which is easily avoided with the block: irb(main):012:0> cx =3D nil =3D> nil irb(main):013:0> callcc { |c| cx =3D c }; puts 'hi' hi =3D> nil irb(main):014:0> cx.call hi =3D> nil irb(main):015:0> cx.call hi =3D> nil irb(main):016:0> cx.call hi =3D> nil The block makes this easy. --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --V3eawNQxI9TAjvgi Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQE/MZTsMypVHHlsnwQRAvimAKDposWIsPsibsrCZuigLmKHedLB5QCdFJ0T hkuwKgMvGjc8Bn5ig2m+oR8= =rFLu -----END PGP SIGNATURE----- --V3eawNQxI9TAjvgi--