• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Continuations in scala (incomplete version)
 

Continuations in scala (incomplete version)

on

  • 1,840 views

a simple introduction to scala's continuation support, not thorough enough.

a simple introduction to scala's continuation support, not thorough enough.

Statistics

Views

Total Views
1,840
Views on SlideShare
1,644
Embed Views
196

Actions

Likes
0
Downloads
15
Comments
0

13 Embeds 196

http://fujohnwang.blogspot.com 168
http://static.slidesharecdn.com 6
http://fujohnwang.blogspot.jp 5
http://fujohnwang.blogspot.hk 4
http://fujohnwang.blogspot.tw 2
http://fujohnwang.github.com 2
http://fujohnwang.blogspot.sg 2
http://paper.li 2
http://fujohnwang.blogspot.com.au 1
url_unknown 1
http://fujohnwang.blogspot.in 1
http://reader.youdao.com 1
https://duckduckgo.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Continuations in scala (incomplete version) Continuations in scala (incomplete version) Presentation Transcript

    • continuations in fujohnwang @Twitter @weiboSaturday, July 9, 2011
    • what’s continuation? Continuation capture the state of a computation(maybe to be invoked later). Simple concept, but hard to get. first-class support in schema languageSaturday, July 9, 2011
    • know CPS first normal control flow structure control flow structure after cps PS.  code  sample  borrowed  from  http://www.slideshare.net/openbala/continuationsSaturday, July 9, 2011
    • WHat’s the big deal?Saturday, July 9, 2011
    • usage scenarios programming design pattern coroutine exception handling web frameworks backtrackingSaturday, July 9, 2011
    • observer pattern with continuationSaturday, July 9, 2011
    • Coroutine? see the blog of jim mcbeatchSaturday, July 9, 2011
    • Exception handling No sample code yetSaturday, July 9, 2011
    • Web Framework with continuation support seaside / smalltalk cocoon / Java http://cocoon.apache.org/2.1/userdocs/flow/continuations.html weblocks / common lisp wee / ruby ocsigen / ocaml more...Saturday, July 9, 2011
    • Saturday, July 9, 2011
    • code pieces function calculator() { var a, b, operator; cocoon.sendPageAndWait("getA.html"); a = cocoon.request.get("a"); cocoon.sendPageAndWait("getB.html"); b = cocoon.request.get("b"); cocoon.sendPageAndWait("getOperator.html"); operator = cocoon.request.get("op"); try { if (operator == "plus") cocoon.sendPage("result.html", {result: a + b}); else if (operator == "minus") cocoon.sendPage("result.html", {result: a - b}); else if (operator == "multiply") cocoon.sendPage("result.html", {result: a * b}); else if (operator == "divide") cocoon.sendPage("result.html", {result: a / b}); else cocoon.sendPage("invalidOperator.html", {operator: operator}); } catch (exception) { cocoon.sendPage("error.html", {message: "Operation failed: " + exception.toString ()}); }Saturday,} 9, 2011 July
    • Continuation types full continuation(aka. first-class cont.) delimited continuation (aka. partial, composable cont.) write async code as sequence one mix cps code and normal code seamlesslySaturday, July 9, 2011
    • What DC looks like? reset  { reset  {        println(1)        println(1)        shift  {  cont  =>        shift  {  cont  =>  }                println(2)        println(2)        } }        println(3) //prints:  1 } //prints:  1  2 reset  {        println(1)   def  is123(n:Int):Boolean  =  {        shift  {  cont  =>         reset  {                cont()             shift  {  k  :  (Int=>String)  =>                println(2)                   (k(n)  ==  "123")        }             }.toString        println(3)         } }   } //prints:  1  3  2Saturday, July 9, 2011
    • first glance with dc reset and shift reset sets up the boundary of dc(‘s cps) shift captures the continuation Result types yield returnSaturday, July 9, 2011
    • puzzle about yield and returnSaturday, July 9, 2011
    • scala cont features compiler plugin + Library compiler plugin does cps transformation library supports control structures and directives serializable (can be saved, distribute sys...) see swarm?! Others?Saturday, July 9, 2011
    • available softwares swarm scalaflow Akka’s DataFlow Concurrency library nio actor implementation for akka nioserverSaturday, July 9, 2011
    • What I want to do with it coroutine combine with java nio resource-efficient minimally-threaded networking layer framework reduce hw cost finallySaturday, July 9, 2011
    • Questions?Saturday, July 9, 2011
    • References http://www.scala-lang.org/node/2096 http://okmij.org/ftp/continuations/Continuations.html http://jim-mcbeath.blogspot.com/2010/08/delimited-continuations.html http://lamp.epfl.ch/~rompf/continuations-icfp09.pdf http://okmij.org/ftp/continuations/index.html http://suereth.blogspot.com/2010/03/how-you-should-think-about-delimited.html http://dcsobral.blogspot.com/2009/07/delimited-continuations-explained-in.html http://blog.richdougherty.com/2009/02/delimited-continuations-in-scala_24.html http://en.wikipedia.org/wiki/Seaside_(software) http://en.wikipedia.org/wiki/Call-with-current-continuation http://community.schemewiki.org/?call-with-current-continuation-for-C-programmers http://community.schemewiki.org/?call-with-current-continuation http://en.wikipedia.org/wiki/Coroutine http://cocoon.apache.org/2.1/userdocs/flow/continuations.html https://github.com/rschildmeijer/loftSaturday, July 9, 2011
    • ThanksSaturday, July 9, 2011