[racket] Strange behavior of web application , or may be not

From: Veer (diggerrrrr at gmail.com)
Date: Mon Jun 27 10:50:14 EDT 2011

This is  really crazy , I wrote large program , and was getting
the same behavior and whole day I tried to figure why and why me?
Of course I forgot that response/xexpr does not
send the response back to client.
So view function becomes :

(define (view request)
    (send/suspend/dispatch
     (lambda (make-url)
       (response/xexpr
        `(html)))))

Thanks



On Mon, Jun 27, 2011 at 7:47 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> This is not strange.
>
> When you click "Create Something", the continuation is []
>
> When you click "Start Again", the continuation is
>
> (begin [] (error 'oops ...) (recur))
>
> When you click "View", the value
>
> (response/xexpr
>     `(html))
>
> gets returned to the continuation, so you get an error, because begin
> ignores the value and drops through to the error.
>
> Jay
>
> 2011/6/27 Veer <diggerrrrr at gmail.com>:
>> Hello,
>>
>> When I run this web application (given below) , I get strange behavior
>>  , don't know if
>> this is correct behavior or not.
>>
>> Follow/click the link in sequence :
>> 1. Create Something
>> 2. Start again
>> 3. View
>>
>> So , when I click "view" I get exception instead of blank page.
>>
>> code :
>> #lang web-server/insta
>> (define (start request)
>>  (do-1 request))
>>
>> (define (do-1 request)
>>  (define (resp make-url)
>>    (response/xexpr
>>     `(html
>>       (body (a ((href ,(make-url view))) "View")
>>             (br)
>>             (a ((href ,(make-url create-something))) "Create something")))))
>>
>>  (define (create-something request)
>>    (recur))
>>
>>  (define (view request)
>>    (response/xexpr
>>     `(html)))
>>
>>  (send/suspend/dispatch resp))
>>
>>
>> (define (recur)
>>  (do-something)
>>  (error 'oops "WHY ARE WE HERE?")
>>  (recur))
>>
>> (define (do-something)
>>  (define (resp make-url)
>>    (response/xexpr
>>     `(html
>>       (body (a ((href ,(make-url start))) "Start again")))))
>>  (send/suspend/dispatch resp))
>>
>>
>> Thanks
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>>
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93
>



Posted on the users mailing list.