Monday 7 January 2013

An Alternate Explanation of Continuations


What's a continuation?

If you read the Wikipedia item on continuations, make sure you understand the "continuation sandwich" paragraph which is supposed to be the definitive example of what a continuation is. I like to think of it the other way around - with my patent "what a continuation is not" example.

What a continuation is not?

Imagine you have a bookies slip with a four horse accumulator bet (parlay) on it. Your first three horses win and you are in a situation (the state of the bet) where you have a small fortune going onto the last horse. The horse falls.

Now, if the bookies slip had been a continuation it would have maintained the state after the third race and you could have retrieved that state and tried another horse on the last race. But it isn't and you can't, so tough.

Continuations are an important concept in the Nagare Microframework which I'll be looking at next. Continuations allow Nagare to maintain state in an exciting way which may seem unusual to you if you have used some of the other python frameworks like Flask or Bottle or Django.

Good luck fellow travellers.

No comments:

Post a Comment