callcc Semantics

B

Bill Atkins

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

Bill
 
M

Mikael Brockman

Bill Atkins said:
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.
 
E

Eric Hodel

--7kD9y3RnPUgTZee0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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 - (e-mail address removed) - 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--
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,420
Latest member
ZitaVos505

Latest Threads

Top