SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
continuations in
                         fujohnwang
                            @Twitter
                              @weibo




Saturday, 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 language




Saturday, 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/continuations




Saturday, July 9, 2011
WHat’s the big deal?




Saturday, July 9, 2011
usage scenarios
               programming design pattern

               coroutine

               exception handling

               web frameworks

               backtracking



Saturday, July 9, 2011
observer pattern with
        continuation




Saturday, July 9, 2011
Coroutine?



               see the blog of jim mcbeatch




Saturday, July 9, 2011
Exception handling



               No sample code yet




Saturday, 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 seamlessly




Saturday, 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	
  2




Saturday, 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

                         return


Saturday, July 9, 2011
puzzle about
      yield and return




Saturday, 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

               nioserver




Saturday, 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 finally



Saturday, 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/loft


Saturday, July 9, 2011
Thanks




Saturday, July 9, 2011

Contenu connexe

Tendances

Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Groupbaroquebobcat
 
Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMDierk König
 
Messages from Perl
Messages from PerlMessages from Perl
Messages from PerlHanae Aoki
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Andres Almiray
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvmArnaud Giuliani
 
What’s new in Kotlin?
What’s new in Kotlin?What’s new in Kotlin?
What’s new in Kotlin?Squareboat
 
FregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMFregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMDierk König
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsAjax Experience 2009
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android DevelopmentSpeck&Tech
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 

Tendances (20)

Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Python master class 2
Python master class 2Python master class 2
Python master class 2
 
Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVM
 
Messages from Perl
Messages from PerlMessages from Perl
Messages from Perl
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
What’s new in Kotlin?
What’s new in Kotlin?What’s new in Kotlin?
What’s new in Kotlin?
 
FregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMFregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVM
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 
Rjb
RjbRjb
Rjb
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android Development
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 

En vedette

Gold investment types introduction
Gold investment types introductionGold investment types introduction
Gold investment types introductionFuqiang Wang
 
Scala funbyexample
Scala funbyexampleScala funbyexample
Scala funbyexampleFuqiang Wang
 
Seed2016 - 개미수열 한주영 (annotated)
Seed2016 - 개미수열 한주영 (annotated)Seed2016 - 개미수열 한주영 (annotated)
Seed2016 - 개미수열 한주영 (annotated)Jooyung Han
 
挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalk挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalkFuqiang Wang
 
Proof and Emacs
Proof and EmacsProof and Emacs
Proof and Emacsdico_leque
 
モナドをつくろう
モナドをつくろうモナドをつくろう
モナドをつくろうdico_leque
 
Architecture patterns and practices
Architecture patterns and practicesArchitecture patterns and practices
Architecture patterns and practicesFuqiang Wang
 
More Than Java Concurrency
More Than Java ConcurrencyMore Than Java Concurrency
More Than Java ConcurrencyFuqiang Wang
 
Zookeeper In Simple Words
Zookeeper In Simple WordsZookeeper In Simple Words
Zookeeper In Simple WordsFuqiang Wang
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinAndrey Breslav
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to ScalaTim Underwood
 

En vedette (13)

Gold investment types introduction
Gold investment types introductionGold investment types introduction
Gold investment types introduction
 
Scala funbyexample
Scala funbyexampleScala funbyexample
Scala funbyexample
 
Seed2016 - 개미수열 한주영 (annotated)
Seed2016 - 개미수열 한주영 (annotated)Seed2016 - 개미수열 한주영 (annotated)
Seed2016 - 개미수열 한주영 (annotated)
 
Kafka简介
Kafka简介Kafka简介
Kafka简介
 
挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalk挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalk
 
Proof and Emacs
Proof and EmacsProof and Emacs
Proof and Emacs
 
モナドをつくろう
モナドをつくろうモナドをつくろう
モナドをつくろう
 
Architecture patterns and practices
Architecture patterns and practicesArchitecture patterns and practices
Architecture patterns and practices
 
SBT Made Simple
SBT Made SimpleSBT Made Simple
SBT Made Simple
 
More Than Java Concurrency
More Than Java ConcurrencyMore Than Java Concurrency
More Than Java Concurrency
 
Zookeeper In Simple Words
Zookeeper In Simple WordsZookeeper In Simple Words
Zookeeper In Simple Words
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in Kotlin
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 

Similaire à Continuations in scala (incomplete version)

The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMVolkan Yazıcı
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Evel xf
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Codemotion
 
Clojure 1.1 And Beyond
Clojure 1.1 And BeyondClojure 1.1 And Beyond
Clojure 1.1 And BeyondMike Fogus
 
Cray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesCray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesJeff Larkin
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded ProgrammingSri Prasanna
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eveguest91855c
 
Our challenge for Bulkload reliability improvement
Our challenge for Bulkload reliability  improvementOur challenge for Bulkload reliability  improvement
Our challenge for Bulkload reliability improvementSatoshi Akama
 
Developing Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormDeveloping Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormLester Martin
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-optJeff Larkin
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019Leonardo Borges
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...Francesco Casalegno
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
C++totural file
C++totural fileC++totural file
C++totural filehalaisumit
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrencyAlex Navis
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8Rafael Casuso Romate
 

Similaire à Continuations in scala (incomplete version) (20)

The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVM
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
 
Clojure 1.1 And Beyond
Clojure 1.1 And BeyondClojure 1.1 And Beyond
Clojure 1.1 And Beyond
 
Cray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesCray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best Practices
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded Programming
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Our challenge for Bulkload reliability improvement
Our challenge for Bulkload reliability  improvementOur challenge for Bulkload reliability  improvement
Our challenge for Bulkload reliability improvement
 
Developing Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormDeveloping Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache Storm
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-opt
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
C++totural file
C++totural fileC++totural file
C++totural file
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrency
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
 

Dernier

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Dernier (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Continuations in scala (incomplete version)

  • 1. continuations in fujohnwang @Twitter @weibo Saturday, July 9, 2011
  • 2. 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 language Saturday, July 9, 2011
  • 3. know CPS first normal control flow structure control flow structure after cps PS.  code  sample  borrowed  from  http://www.slideshare.net/openbala/continuations Saturday, July 9, 2011
  • 4. WHat’s the big deal? Saturday, July 9, 2011
  • 5. usage scenarios programming design pattern coroutine exception handling web frameworks backtracking Saturday, July 9, 2011
  • 6. observer pattern with continuation Saturday, July 9, 2011
  • 7. Coroutine? see the blog of jim mcbeatch Saturday, July 9, 2011
  • 8. Exception handling No sample code yet Saturday, July 9, 2011
  • 9. 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
  • 11. 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
  • 12. 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 seamlessly Saturday, July 9, 2011
  • 13. 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  2 Saturday, July 9, 2011
  • 14. first glance with dc reset and shift reset sets up the boundary of dc(‘s cps) shift captures the continuation Result types yield return Saturday, July 9, 2011
  • 15. puzzle about yield and return Saturday, July 9, 2011
  • 16. 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
  • 17. available softwares swarm scalaflow Akka’s DataFlow Concurrency library nio actor implementation for akka nioserver Saturday, July 9, 2011
  • 18. What I want to do with it coroutine combine with java nio resource-efficient minimally-threaded networking layer framework reduce hw cost finally Saturday, July 9, 2011
  • 20. 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/loft Saturday, July 9, 2011