Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > callcc Semantics

Reply
Thread Tools

callcc Semantics

 
 
Bill Atkins
Guest
Posts: n/a
 
      10-18-2004
What is the purpose of the block passed to callc? Is there a reason
that callcc doesn't just return the Continuation object?

Bill


 
Reply With Quote
 
 
 
 
Mikael Brockman
Guest
Posts: n/a
 
      10-18-2004
Bill Atkins <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
 
Eric Hodel
Guest
Posts: n/a
 
      10-19-2004
--7kD9y3RnPUgTZee0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Bill Atkins ((E-Mail Removed)) 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=3Dsit...alk.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://www.velocityreviews.com/forums/(E-Mail 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)

iD8DBQFBdI5AMypVHHlsnwQRAtWOAJ9OFHI5943eawiHoA07V3 rXN/gztQCg9Beb
S33sCJOPhMcvvm/63TzTcV8=
=/XQL
-----END PGP SIGNATURE-----

--7kD9y3RnPUgTZee0--


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with callcc (or yield?) mepython Ruby 0 03-03-2005 06:00 PM
Callcc problem in Generator Greg Fitzgerald Ruby 0 01-25-2005 06:35 AM
callcc performance non-linear wrt stack size - why? Mikael Brockman Ruby 2 09-25-2004 06:52 PM
ruby, actors, continuations, Kernel#callcc zuzu Ruby 14 08-23-2004 03:02 AM
Why does Ruby have callcc? Jim Bob Ruby 22 08-08-2003 01:28 PM



Advertisments