Understanding continuations

rubyists-

i am trying to grok continuations, and only barely understand them.

my goal is to implement an Enumerable#next method which uses
Enumerable#each_with_index and callcc. i have one or two ways which work, but
recurse infinitely… my main problem is how to know when each_with_index is
on the last item! however, i really don’t understand what i’m doing! if
anyone can provide more insight into continuations than the pickaxe, i’d
appreciate it.

-ara

···

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

I was once like you are now, and I know that it’s not easy,
To be calm when you’ve found something going on.
But take your time, think a lot,
Why, think of everything you’ve got.
For you will still be here tomorrow, but your dreams may not.

Son
How can I try to explain, when I do he turns away again.
It’s always been the same, same old story.
From the moment I could (ruby-)talk(20270) I was ordered to listen.
Now there’s a way and I know that I have to go away.
I know I have to go.

Bye,
Pit

···

On 15 Nov 2002 at 3:20, ahoward wrote:

rubyists-

i am trying to grok continuations, and only barely understand them.

my goal is to implement an Enumerable#next method which uses
Enumerable#each_with_index and callcc. i have one or two ways which
work, but recurse infinitely… my main problem is how to know when
each_with_index is on the last item! however, i really don’t
understand what i’m doing! if anyone can provide more insight into
continuations than the pickaxe, i’d appreciate it.

i am trying to grok continuations, and only barely understand them.

In short, a continuation is an image of the stack. Imagine this:

root of a function call tree
_

_
_
_ save continuation
_ invoke continuation

Upon invocation, the current stack is replaced by the one from the
continuation, and you jump back to where you were.

···

ahoward (ahoward@fsl.noaa.gov) wrote:


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

[snip]

From the moment I could (ruby-)talk(20270) I was ordered to listen.
[snip]

as far as i can tell, 20270 has no children, closing with

“If somebody needs to traverse multiple enumerables in parallel and
doesn’t want to use matz’s solution in the FAQ which uses threads
then write me and I’ll finally take the time to publish the code”

well?

the solution of 20270 is good, but not generic. i’m working on doing
something which will work in Enumerable, which means using only :===, :each,
and :<=>

good pointers in there though… i will endevour to understand it.

-a

···

On Fri, 15 Nov 2002, Pit Capitain wrote:

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

I nominate this for most poetic post of the month.
I don’t know the song, though it sounds like Harry
Chapin to me. (self.date!)

Hal

···

----- Original Message -----
From: “Pit Capitain” pit@capitain.de
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, November 14, 2002 1:17 PM
Subject: Re: understanding continuations

On 15 Nov 2002 at 3:20, ahoward wrote:

rubyists-

i am trying to grok continuations, and only barely understand them.

my goal is to implement an Enumerable#next method which uses
Enumerable#each_with_index and callcc. i have one or two ways which
work, but recurse infinitely… my main problem is how to know when
each_with_index is on the last item! however, i really don’t
understand what i’m doing! if anyone can provide more insight into
continuations than the pickaxe, i’d appreciate it.

I was once like you are now, and I know that it’s not easy,
To be calm when you’ve found something going on.
But take your time, think a lot,
Why, think of everything you’ve got.
For you will still be here tomorrow, but your dreams may not.

Son
How can I try to explain, when I do he turns away again.
It’s always been the same, same old story.
From the moment I could (ruby-)talk(20270) I was ordered to listen.
Now there’s a way and I know that I have to go away.
I know I have to go.

Right era, wrong singer-songwriter. It’s Yusuf Islam. Free trip to
Hawaii for the first one who can tell us what he called himself when he
wrote that song!

···

On Fri, Nov 15, 2002 at 11:20:46AM +0900, Hal E. Fulton wrote:

Son
How can I try to explain, when I do he turns away again.
It’s always been the same, same old story.
From the moment I could (ruby-)talk(20270) I was ordered to listen.
Now there’s a way and I know that I have to go away.
I know I have to go.

I nominate this for most poetic post of the month.
I don’t know the song, though it sounds like Harry
Chapin to me. (self.date!)


Matt Gushee When a nation follows the Way,
Englewood, Colorado, USA Horses bear manure through
mgushee@havenrock.com its fields;
http://www.havenrock.com/ When a nation ignores the Way,
Horses bear soldiers through
its streets.

                        --Lao Tzu (Peter Merel, trans.)

Kat Stevens

···

Right era, wrong singer-songwriter. It’s Yusuf Islam. Free trip to
Hawaii for the first one who can tell us what he called himself when he
wrote that song!

In article 20021115023200.GB1718@swordfish,

···

Matt Gushee mgushee@havenrock.com wrote:

On Fri, Nov 15, 2002 at 11:20:46AM +0900, Hal E. Fulton wrote:

Son
How can I try to explain, when I do he turns away again.
It’s always been the same, same old story.
From the moment I could (ruby-)talk(20270) I was ordered to listen.
Now there’s a way and I know that I have to go away.
I know I have to go.

I nominate this for most poetic post of the month.
I don’t know the song, though it sounds like Harry
Chapin to me. (self.date!)

Right era, wrong singer-songwriter. It’s Yusuf Islam. Free trip to
Hawaii for the first one who can tell us what he called himself when he
wrote that song!

That’d be Cat Stevens - am I a winner?

Phil

Hi –

···

On Fri, 15 Nov 2002, Ian MacLean wrote:

Right era, wrong singer-songwriter. It’s Yusuf Islam. Free trip to
Hawaii for the first one who can tell us what he called himself when he
wrote that song!

Kat Stevens

Cat, wasn’t it? (Hey, not trying to be pedantic, just never been to
Hawaii! :slight_smile:

David


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

you’re right. see http://www.mountainoflight.co.uk/ or
http://catstevens.com/
Ian

···

Cat, wasn’t it? (Hey, not trying to be pedantic, just never been to
Hawaii! :slight_smile:

David