Scala: Delimited Continents Explained - Not

Interested in the concept of continuing, I started reading wiki posts and came up with this β€œsimple” example:

reset { ... shift { k: (Int=>Int) => // the continuation k will be the '_ + 1' below k(7) } + 1 } // result: 8 

Without knowing Scala, I was completely lost here, I could not understand how 8 would come out.

Below I tried to understand the meaning, but could not. Any guy please give me a short explanation? Yes, there are Scala grammar books, but they are too thick, I'm more interested in understanding the concept of continuation of continuation than the main language of Scala ...

  • (Int=>Int)

    It looks like a C # delegate, Int input, Int output.

  • k: (Int=>Int) => k(7)

    I got lost here ... what is k and what is (Int => Int) => k (7)?

  • shift { k: (Int=>Int) => k(7) } + 1

    Even more lost ...

  • reset { ...; shift { k: (Int=>Int) => k(7) } + 1 }

    More and more lost ...

+3
source share
2 answers

I found a Chris League report, "Monadologie: Professional Help for Type Anxiety" ( http://vimeo.com/13304075 ) contains one of the best examples of separation sequel.

+2
source

fotNelton, thanks a lot! Answer Alex No, the link helped me. Now I think I understand. Let me answer my question to postpone it as a note.

Grammar reset and shift:

 reset { ... shift { cf: (InputParameterType => OutpututParameterType) => CodeBlockInsideShift } CodeBlockAfterShiftBeforeEndOfReset } 

Actually this means that in C # style pseudo-code:

 public delegate OutpututParameterType CFDelegate(InputParameterType); CFDelegate cf = CodeBlockAfterShiftBeforeEndOfReset; CodeBlockInsideShift; 
+1
source

All Articles