SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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