callcc Semantics

Discussion in 'Ruby' started by Bill Atkins, Oct 18, 2004.

  1. Bill Atkins

    Bill Atkins Guest

    What is the purpose of the block passed to callc? Is there a reason
    that callcc doesn't just return the Continuation object?

    Bill
    Bill Atkins, Oct 18, 2004
    #1
    1. Advertising

  2. Bill Atkins <> writes:

    > What is the purpose of the block passed to callc? Is there a reason
    > that callcc doesn't just return the Continuation object?


    The block isn't part of the continuation. Try writing

    | catch :break do
    | callcc do |$k|
    | puts 'hello'
    | throw :break
    | end
    | puts 'world'
    | end

    using only returncc.
    Mikael Brockman, Oct 18, 2004
    #2
    1. Advertising

  3. Bill Atkins

    Eric Hodel Guest

    --7kD9y3RnPUgTZee0
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Bill Atkins () wrote:

    > What is the purpose of the block passed to callc? Is there a reason
    > that callcc doesn't just return the Continuation object?


    This has been discussed at least once in the past, see the ruby-talk
    email archives:

    http://www.google.com/search?q=3Dsite:ruby-talk.org callcc

    I will say that call-with-current-continuation cannot work without the
    block passed to it. IOW, call (this block of code) with the current
    continuation (which gets passed to it as an argument).

    x =3D callcc do |cc| ... end
    ^^
    Here || is the "current continuation" for callcc. Without the block,
    you can't return here and not do whatever was done in the block. This
    is very important, without it you can't do much truly interesting stuff.

    --=20
    Eric Hodel - - http://segment7.net
    All messages signed with fingerprint:
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


    --7kD9y3RnPUgTZee0
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (FreeBSD)

    iD8DBQFBdI5AMypVHHlsnwQRAtWOAJ9OFHI5943eawiHoA07V3rXN/gztQCg9Beb
    S33sCJOPhMcvvm/63TzTcV8=
    =/XQL
    -----END PGP SIGNATURE-----

    --7kD9y3RnPUgTZee0--
    Eric Hodel, Oct 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Bob

    Why does Ruby have callcc?

    Jim Bob, Aug 6, 2003, in forum: Ruby
    Replies:
    22
    Views:
    240
  2. zuzu
    Replies:
    14
    Views:
    231
    Phil Tomson
    Aug 23, 2004
  3. Mikael Brockman
    Replies:
    2
    Views:
    131
    Mikael Brockman
    Sep 25, 2004
  4. Greg Fitzgerald

    Callcc problem in Generator

    Greg Fitzgerald, Jan 25, 2005, in forum: Ruby
    Replies:
    0
    Views:
    179
    Greg Fitzgerald
    Jan 25, 2005
  5. mepython
    Replies:
    0
    Views:
    113
    mepython
    Mar 3, 2005
Loading...

Share This Page