views:

92

answers:

1
+3  Q: 

nested CPS "reset"

Hi, using the CPS compiler-plugin of Scala 2.8, there are the two magic controls reset and shift. Reset delimits the continuation and shift captures the continuation.

There is an example of using CPS with NIO, using nested resets as a type of "forking"...? I don't exactly understand the purpose of nesting the resets, what's the effect?

+1  A: 

There's nothing magic about nested a reset. A shift applies to the innermost reset that encloses it. The pseudo-forking comment you see is just a description of the effective behavior from the callbacks registered with the NIO selector.

Mitch Blevins
Thanks for your answer! I still do not fully understand why the read/write handlers need a different continuation-delimitation and the primary reset() for accepting the connections won't suffice.
hotzen