Various use of continuations in Kahua Applications in practical web programming experience <ul><ul><li>Katsutohi Itoh </li...
Higher-Level APIs for web-applications
Continuation for web-application <ul><li>Continuation passing style is easy to write control flow on web programming. </li...
Continuation of components How continuations of components work? component page -> page component -> component? component ...
Start from this issue by “Take THE Arc Challenge” http://www.paulgraham.com/arcchallenge.html Write a program: <ul><li>Pro...
Easy to write control flow ;; said ( define-entry  (said)‏ ( page (form/cont/ (@@/ ( cont  ( lambda  ()‏ (let1 say (kahua-...
Individual component <ul><li>In practical web applications </li></ul><ul><li>Many components  co-exist in most web pages <...
Motivation We want to write like this: The “said5” has 5 individual “said” components. ;; using individual “said” (define-...
How about this? ;; Does this “said” works individually? ( define  (said id)‏ (form/cont/ (@@/ ( cont  ( lambda  ()‏ (let1 ...
Diff : Said application ( define-entry  (said)‏ ( page (form/cont/ (@@/ ( cont  ( lambda  ()‏ (let1 say (kahua-context-ref...
( define-entry  (said  id )‏ (form/cont/ (@@/ ( cont  ( lambda  ()‏ (let1 say (kahua-context-ref  &quot;say&quot; )‏ (a/co...
The problem Continuation generates  the whole page Each component to be  independent from the others Expected Happened Con...
Solution : parts-cont <ul><li>;; this “said” works as we expected </li></ul><ul><li>( define  (said person)‏ </li></ul><ul...
Diff : buggy said component <ul><li>( define  (said person)‏ </li></ul><ul><li>(form/cont/ </li></ul><ul><li>(@@/ </li></u...
<ul><li>( define  (said person)‏ </li></ul><ul><li>(form/cont/  (@/ (id person))‏ </li></ul><ul><li>(@@/  (target person) ...
What “parts-cont” does Alf Willie Brian Lynn Kate Input form Anchor link Show text submit! click! form link Text form form...
What “parts-cont” does body link text form link link html link Generate the whole html tree by the continuation of Brian's...
Mechanism : the key idea Create continuation that generate next page by replace target node with a new node which return f...
Design of the mechanism create continuation that generate next page by replace target node with a new node which return fr...
More ... The “parts-cont” mechanism highlights a new need  to keep client-side context
Keep client-side context <ul><li>;; “said” with “keep” </li></ul><ul><li>( define  (said id)‏ </li></ul><ul><li>(form/cont...
A more interesting sample ;; this “calendar/” function works as a widget of date selector. (define-entry (plan)‏ (page (fo...
Design of the mechanism client-side context Server interpreter Continuation to generate page with keeping client-side cont...
Now, we have ... The “parts-cont” mechanism, which supports individual components. We can write web application  in smart ...
What next? Refine the design of “parts-cont” mechanism. Challenge this by using partial continuation technique.
What next? Of course, Fix  some known bugs  of parts-cont...
Thank you
Upcoming SlideShare
Loading in …5
×

Various use of continuations in Kahua - Application in practical web programming experience

649 views

Published on

Kahua is a continuation passing style (CPS) application framework and server, in which we have developed and been serving several practical web applications.

From our experience we implemented number of higher-level APIs that wraps different aspects of continuations to capture the common idioms in web-application programming. Using them makes web-application development much easier than using bare call/cc and shift/reset primitives. In this presentation, we explain the implementation and usage of them, based on actual examples we encountered during the development.

Spearker's profile: Katsutoshi Itoh is a member of Kahua project since 2005.

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Hello my dear
    I am Modester by name good day. i just went to your profile this time true this site (www.slideshare.net) and i got your detail and your explanation in fact the way you explain your self shows me that you are innocent and maturity and also understand person i decided to have a contact with you so that we can explain to our self each other because God great everyone to make a friend with each other and from that we know that we are from thism planet God great for us ok my dear please try and reach me through my email address (modester4life4@yahoo.c/o/m) so that i can send you my picture true your reply we can know each other ok have a nice day and God bless you yours Modester
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
649
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
12
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Various use of continuations in Kahua - Application in practical web programming experience

  1. 1. Various use of continuations in Kahua Applications in practical web programming experience <ul><ul><li>Katsutohi Itoh </li></ul></ul><ul><ul><li>Kahua Project </li></ul></ul>
  2. 2. Higher-Level APIs for web-applications
  3. 3. Continuation for web-application <ul><li>Continuation passing style is easy to write control flow on web programming. </li></ul><ul><li>But to write practical web applications, we want to deal with: </li></ul><ul><ul><li>Individual components (like widgets)‏ </li></ul></ul>
  4. 4. Continuation of components How continuations of components work? component page -> page component -> component? component -> page? component HTML HTML HTML HTML click here click here Hello,Mr.
  5. 5. Start from this issue by “Take THE Arc Challenge” http://www.paulgraham.com/arcchallenge.html Write a program: <ul><li>Produce a page with an input field & a submit button. </li></ul><ul><li>When input text is submitted, display an anchor link saying “click here”. </li></ul><ul><li>When the link is clicked, display the text posted to the first page. </li></ul>
  6. 6. Easy to write control flow ;; said ( define-entry (said)‏ ( page (form/cont/ (@@/ ( cont ( lambda ()‏ (let1 say (kahua-context-ref &quot;say&quot; )‏ ( page (a/cont/ (@@/ ( cont ( lambda ()‏ ( page (p/ &quot;you said: &quot; say)))))‏ &quot;click here&quot; ))))))‏ (readln/ &quot;say&quot; )‏ (submit/))))‏ Call continuation procedure Generate page
  7. 7. Individual component <ul><li>In practical web applications </li></ul><ul><li>Many components co-exist in most web pages </li></ul><ul><li>Want some kind of components to work individually </li></ul><ul><ul><li>ex. Something to redraw a part of page – login box embedded in page like as reddit.com, calendar as date selector at any blog site ... </li></ul></ul><ul><li>Not want a component's continuation to have the whole next page </li></ul>
  8. 8. Motivation We want to write like this: The “said5” has 5 individual “said” components. ;; using individual “said” (define-entry (said5)‏ ( page (map/ said '( ”Alf” “Willie” “Kate” “Lynn” “Brian” ))))‏
  9. 9. How about this? ;; Does this “said” works individually? ( define (said id)‏ (form/cont/ (@@/ ( cont ( lambda ()‏ (let1 say (kahua-context-ref id)‏ (a/cont/ (@@/ ( cont ( lambda ()‏ (p/ id &quot; said: &quot; say))))‏ &quot;click here&quot; )))))‏ (readln/ id)‏ (submit/)))‏ ;;http://localhost/app/said5 (define-entry (said5)‏ ( page (map/ said '(“ Alf” “Willie” “Kate” “Lynn” “Brian” ))))‏ Call continuation procedure Generate page
  10. 10. Diff : Said application ( define-entry (said)‏ ( page (form/cont/ (@@/ ( cont ( lambda ()‏ (let1 say (kahua-context-ref &quot;say&quot; )‏ ( page (a/cont/ (@@/ ( cont ( lambda ()‏ ( page (p/ &quot;you said: &quot; say)))))‏ &quot;click here&quot; ))))))‏ (readln/ &quot;say&quot; )‏ (submit/))))‏
  11. 11. ( define-entry (said id )‏ (form/cont/ (@@/ ( cont ( lambda ()‏ (let1 say (kahua-context-ref &quot;say&quot; )‏ (a/cont/ (@@/ ( cont ( lambda ()‏ (p/ id &quot; said: &quot; say))))‏ &quot;click here&quot; )))))‏ (readln/ &quot;say&quot; )‏ (submit/)))‏ Diff : Said component(?)‏
  12. 12. The problem Continuation generates the whole page Each component to be independent from the others Expected Happened Continuation must know the others Continuation does not have to know the others
  13. 13. Solution : parts-cont <ul><li>;; this “said” works as we expected </li></ul><ul><li>( define (said person)‏ </li></ul><ul><li>(form/cont/ (@/ (id person))‏ ;; 3.form has the target id </li></ul><ul><li>(@@/ (target person) ‏ ;; 2.update a target-id's node </li></ul><ul><li>( parts-cont ;; 1.generate new node </li></ul><ul><li>( lambda ()‏ </li></ul><ul><li>(let1 say (kahua-context-ref person)‏ </li></ul><ul><li>(div/ (@/ (id person))‏ </li></ul><ul><li>(a/cont/ (@@/ (target person) ‏ </li></ul><ul><li>( parts-cont </li></ul><ul><ul><ul><ul><ul><li>( lambda ()‏ </li></ul></ul></ul></ul></ul><ul><li>(p/ person &quot; said: &quot; say))))‏ </li></ul><ul><li>&quot;click here&quot; )))))‏)‏ </li></ul><ul><li>(readln/ person)‏ </li></ul><ul><li>(submit/)))‏ </li></ul>
  14. 14. Diff : buggy said component <ul><li>( define (said person)‏ </li></ul><ul><li>(form/cont/ </li></ul><ul><li>(@@/ </li></ul><ul><li>( cont </li></ul><ul><li>( lambda ()‏ </li></ul><ul><li>(let1 say (kahua-context-ref person)‏ </li></ul><ul><li>(a/cont/ (@@/ </li></ul><ul><li>( cont </li></ul><ul><ul><ul><ul><ul><li>( lambda ()‏ </li></ul></ul></ul></ul></ul><ul><li>(p/ person &quot; said: &quot; say))))‏ </li></ul><ul><li>&quot;click here&quot; )))))‏ </li></ul><ul><li>(readln/ person)‏ </li></ul><ul><li>(submit/)))‏ </li></ul>
  15. 15. <ul><li>( define (said person)‏ </li></ul><ul><li>(form/cont/ (@/ (id person))‏ </li></ul><ul><li>(@@/ (target person) ‏ </li></ul><ul><li>( parts-cont </li></ul><ul><li>( lambda ()‏ </li></ul><ul><li>(let1 say (kahua-context-ref person)‏ </li></ul><ul><li>(div/ (@/ (id person))‏ </li></ul><ul><li>(a/cont/ (@@/ (target person) ‏ </li></ul><ul><li>( parts-cont </li></ul><ul><ul><ul><ul><ul><li>( lambda ()‏ </li></ul></ul></ul></ul></ul><ul><li>(p/ person &quot; said: &quot; say))))‏ </li></ul><ul><li>&quot;click here&quot; )))))‏)‏ </li></ul><ul><li>(readln/ person)‏ </li></ul><ul><li>(submit/)))‏ </li></ul>Diff : parts-cont version
  16. 16. What “parts-cont” does Alf Willie Brian Lynn Kate Input form Anchor link Show text submit! click! form link Text form form form link link link Text Text Text Make each “said” to work individually
  17. 17. What “parts-cont” does body link text form link link html link Generate the whole html tree by the continuation of Brian's “said” Alf Willie Kate Lynn Brian head
  18. 18. Mechanism : the key idea Create continuation that generate next page by replace target node with a new node which return from “parts-cont” clause
  19. 19. Design of the mechanism create continuation that generate next page by replace target node with a new node which return from “parts-cont” clause Server interpreter Continuation to generate page Continuation to generate node HTML tree
  20. 20. More ... The “parts-cont” mechanism highlights a new need to keep client-side context
  21. 21. Keep client-side context <ul><li>;; “said” with “keep” </li></ul><ul><li>( define (said id)‏ </li></ul><ul><li>(form/cont/ (@/ (id id))‏ </li></ul><ul><li>(@@/ (target id)‏ (keep #t)‏ ;; only add keep clause </li></ul><ul><li>( parts-cont </li></ul><ul><li>( lambda ()‏ </li></ul><ul><li>(let1 say (kahua-context-ref id)‏ </li></ul><ul><li>(div/ (@/ (id id))‏ </li></ul><ul><li>(a/cont/ (@@/ (target id) (keep #t)‏ </li></ul><ul><li>( parts-cont </li></ul><ul><ul><ul><ul><ul><li>( lambda ()‏ </li></ul></ul></ul></ul></ul><ul><li>(p/ id &quot; said: &quot; say))))‏ </li></ul><ul><li>&quot;click here&quot; )))))‏)‏ </li></ul><ul><li>(readln/ id)‏ </li></ul><ul><li>(submit/)))‏ </li></ul>
  22. 22. A more interesting sample ;; this “calendar/” function works as a widget of date selector. (define-entry (plan)‏ (page (form/cont/ (@@/ (cont (entry-lambda (:keyword from to memo)‏ (make <plan> :from from :to to :memo memo)‏ (plan))))‏ ( calendar/ ”from” ”Start” (current-date) )‏ ( calendar/ ”to” ”End” (current-date) )‏ (readtext/ ”memo” )‏ (submit/))‏ (map/ display/ (sort (coerce-to <list> (make-kahua-collection <plan>)) plan>=?))))‏
  23. 23. Design of the mechanism client-side context Server interpreter Continuation to generate page with keeping client-side context Continuation to generate node HTML tree
  24. 24. Now, we have ... The “parts-cont” mechanism, which supports individual components. We can write web application in smart way.
  25. 25. What next? Refine the design of “parts-cont” mechanism. Challenge this by using partial continuation technique.
  26. 26. What next? Of course, Fix some known bugs of parts-cont...
  27. 27. Thank you

×