Adding duals of generators in form of accumulators is a great idea. However, the accumulator protocol does not look as if it is the right one:

When a generator is created, it is given some state. Until this state is exhausted (in a metaphorical sense), the generator produces values by invoking it, after which it produces an eof object. Note that the consumer of the generator is not concerned with the generator's state (only its constructor).

Dualizing this, should give the notion of an accumulator. Here, the state is being built-up by having a producer invoking the accumulator with values until the produces invokes it with an eof object.

In the current proposal, the accumulator now returns its state, meaning that the producer suddenly becomes concerned with the accumulator's state, not the constructor of the accumulator. This looks wrong.

An accumulator protocol more dual to the generator protocol seems to be to add a callback function to every accumulator constructor. This callback function is then invoked as soon as the eof object has been fed into the accumulator. The callback function may take more than one value (it makes no sense to restrict the state to one value).

Example (evaluating to the number of datums that can be read from port):

(call/cc
 (lambda (return)
  (let ((counter (count-accumulator return)))
    (let loop () (counter (read port))))))

Marc