[plt-scheme] Savers: Superceding

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu Feb 18 06:45:39 EST 2010

On Thu, Feb 18, 2010 at 4:18 AM, Synx <plt at synx.us.to> wrote:
> The problem with my implementation is that accumulate doesn't go away,
> and I don't know how to make it go away. I end up calling
> (accumulate-save bytes) which then checks (eq? left #f) and then calls
> (port-save bytes). I would rather just have it call (port-save bytes)
> for the rest of the stream, instead of doing what effectively amounts to:

What you want is a continuation, in the "what do I do next?" sense,
rather than the call/cc sense. Accumulate should have a mutable cell
that stores a continuation function. Whilst accumulating this cell
stores a function that accumulates bytes somewhere. When amount bytes
have been accumulated mutate this cell to store a function that does
whatever the post accumulation function is.

At least I think that's what you want to do. I found it very hard to
follow your code and description above. For example, you talk about
byte streams but I don't see any representation of byte streams in
your code.

You might be interested in Clojure's chunked sequences.


Posted on the users mailing list.