[racket] Parameters and servlets

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Jan 22 13:56:46 EST 2014

On Tue, Jan 21, 2014 at 11:03 AM, antoine <antoine.brand at sfr.fr> wrote:
> Bonjour,
>
> I think the parameterize approach didn't work because of:
>
> (parameterize ([request-data (extract-the-data req)])
>               (responce/output (lambda (out) (request-data))))
>
> The lambda is put into a response struct, and the call to this
> lambda is done outside the scope of the parameterize.

You could do something like this:

(define-syntax-rule
  (paramda args . body)
  (let ([the-params (current-parameterization)])
    (lambda args
      (call-with-parameterization
       the-params
       (λ () . body)))))

(paramda (out) (request-data))

This way, whenever the lambda is eventually called, it will be called
using the same parameters as when it was created.

Jay

>
> I am not sure to understand you about HTTP request.
>
> I will explicit what i think is done (in the current implementation):
>
> - Initialisation of a tcp connection
> - Client sent an HTTP request
> - Server create a thread (in the actual implementation) do the work and return a response
> - end of tcp connection
>
> Am i right?
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/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.