Monday, 15 June 2015

webserver - Understanding send/suspend/dispatch in Racket Web Framework -


I am trying to understand an example related to sending / suspending / sending in Racket Web Framework Tutorial.

Here is the code that makes me puzzle:

  #lang web-server / insta; Start: Request - & gt; Feedback (define (start request) (show-counter 0 request)); Show Counter: Number Request - & gt; not return; Displays the number of hyperlinks: when the link is pressed; Increases the number of new pages (Define (Show-Counter N Request) (Local (Response Generator Embed / URL) (Response / XXPR (Head (Title "Count Example")) (Body (A (( Href (embed / url next-number-handler)), (number- & gt; string n)))) (define (next number-operator request) (show-counter (+ n 1) request)]] (Send / Suspend / Send Response Generator)))  

I have two questions (Most important) where the embed / url is defined? I do not know that it is defined in this code, but my understanding of continuity is low because it is something I'm missing out on.

What is the purpose of the local? I can remove it and the code only works one.

  (defined generator embed / url) ...)  

Continuity "(next number operator here)" generates a URL 2. The function `Response-generator` is called as argument with` p`. Page 3. (HTML ..., (embed-url next-number-handler)) is generated (note: (embed-url next-number-handler) calls `p` and the resultant URL is inserted into the page ) 4. Send [Send] page has been sent to the client 5. [Suspended] The server has suspended the program. [Send] receives the generated request by clicking on the link that was generated in URL 3. Handler associated with the URL (the next number of handlers here) is seen,

is not necessary to use sending / suspending / sending , though here The sketch is:

  (define (Send / Suspend / Send Response-Generator) (Let's / EC escape (define (callback-> URL callback) (Let's / EC Return-URL (Escape (callback (send / send url / suspend))) () Send / return (counterfeit Generate tow Colbak- & gt; URL))))  

No comments:

Post a Comment