Bob Rogers wrote:
From: "Leopold Toetsch via RT" <[EMAIL PROTECTED]>
Yep. At least as long we don't have better support for creating limited continuations that are able to return some results. I'm afraid I don't follow. What would you consider better?
Limiting the callframe range, where the continuation can go. Currently creating a continuation is rather expensive, as all RetContinuations up the call chain are converted into full continuations. This is necessary because there is no further information about the usage of the continuation. It could be passed to 'main' and then 'jump' back. Thus all the intermediate frames have to be kept alive, because normal function return goes through these frames.
But, FWIW, I am coming around to the view that continuations shouldn't ever be invoked like this. Plain function calling is likely to confuse optimizers, since they won't understand that you don't ever expect to return. I was about to propose a new op when I discovered that tailcall works just fine for this purpose (see below).
I don't think that we can enforce this. Have a look at t/library/streams.t. I don't think that a compiler has the knowledge that it's compiling the invocation of a continuation instead of a plain subroutine.
The tailcall syntax works, because it's just ignored by the continuation. leo