call/cc

Stephen Weeks sweeks@research.nj.nec.com
Wed, 24 Mar 1999 10:53:47 -0500


> As for the technical aspects, couldn't you do something like this: if you
> use a fixed stack size, which is definable by the user and, at stack
> overflow just copy to the heap (which remains variable in size) and then
> implement call/cc like you have in mind, it could be used very efficiently
> and still be no burden for a "normal" programmer who would just take the
> stack very large. The call/cc programmer would rather take the stack small
> and it apparently turns out in practice that small stacks do not seriously
> decrease performance... This should not be very hard to implement (I am
> not sure though, but Mike assured me) It only requires some changes in the
> runtime system and (according to Mike) shouldn't take more than a week to
> implement which means perhaps a few days for you ;-) 
> 
> Anyway, Richard Kelsey knows a lot about this, so it might be worth
> talking to him about it...

I talked with Richard about it yesterday, and what you describe is
basically what he does in Scheme48, except that he copies one frame at
a time.

The one issue, which I guess doesn't come up in Scheme48, is the
exception stack, which in mlton is a linked list threaded through the
normal stack.  If the stack isn't in contiguous memory, then it seems
to me that copying (parts of) the stack, either for call/cc or for
copying gc, requires updating this linked list.

> It is a request and it is up to the mlton developers to decide... If you
> don't have time or don't think it's worth it, I am not in the position to
> say anything. However, we really beleive that it is important for a good
> ML implementation to have call/cc and specialization is its first
> application. Is that convincing?

Yes.  It probably won't happen right away (unless you or Mike wants to
give it a try -- I'd be happy to help), but I will put it on my ever
growing todo list.

> >Also, I am leaving NEC at the end of this week to take a new job.  I
> >will still be working some of the time on mlton, but not nearly as
> >much.  It's probably best to send email to (or at least cc)
> >mlton@research.nj.nec.com because mail there goes to me as well as to
> >others working on mlton (for now, henry@research.nj.nec.com and suresh
> >@research.nj.nec.com).  Or, if you think it may be of general
> >interest, mlton-discuss is fine too.  Thanks.
> 
> Ah, ok, I'll keep that in mind. Are you then going back to cmu then?

Nope.  I'm heading out to silicon valley to work for an ecommerce
company called InterTrust.

> Thanks for considering our request!

You're welcome.  I agree call/cc would be a nice thing to have, and
think it can be provided with imperceptible cost to programmers that
don't want to use it.

I'm still curious to hear if you think my original simple
implementation would be at all useful.  I think it would be quite fast
to put in.