cps (continuation passing style) in scala
DESCRIPTION
Continuation-Passing Style (CPS) in Scala presented at CHENSE meetup held Jan 4 2014.TRANSCRIPT
CPSCONTINUATION PASSING
STYLEWITH SCALA
CHENSE Meetup, 4/1/14
ABOUT MEPrasanna Kumar
A Java/Scala programmerfind me @prasseemail me
fork me in githubhttp://github.com/prassee
prassee dot sathian at gmail dotcom
WHAT'S COOL ABOUTCONTINUATIONS ?
"Imagine an abstraction which takes youback to a point of failure in a code sothat you can run it again" - Continuations
lets you to do this !!!!
CPSCONTINUATIONS-PASSING STYLE
"Continuation-Passing Style(CPS) is a style of programmingin which control is passedexplicitly in the form of a
continuation. It also helps theprogrammers to control theexecution flow of the program
at runtime"CPS is a functional programming techniqueScala has support for "Delimited"ContinuationsDelimited Continuation limits the scope ofContinuation in a certain boundary
CPS IN SCALAScala has two keywords for CPS - reset andshiftshift must be contained with-in reset.Since Scala supports 'delimited' CPS thescope of the code for CPS is contained within the reset block
A simple examplereset { shift { k: (Int=>Int) => // The continuation k will be the '_ + 1' below. k(7) } + 1}// Result: 8
CPS'ED FILE READING
USAGE SCENARIOSException HandlingXXX protocol handler (web frameworks !!!)BacktrackingAPI development
QUESTIONS
COURTESYHTML 5CSS 3reveal.js
THANKS :-)