[plt-scheme] Parameters and servlets

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Feb 17 11:58:26 EST 2006

Jay McCarthy wrote:
> On 2/16/06, *Jens Axel Søgaard* <jensaxel at soegaard.net 
> <mailto:jensaxel at soegaard.net>> wrote:
>     Thanks for the explanation. Your web-cells might do the trick.
>     I am trying to make a small library that uses site-wide defaults.
>     E.g in "view.scm" I'd like to write
>        (require "html.scm")
>        ;;;
>        ;;;
>        (current-page-title       "Foo 2.0")
>        (current-page-header      '(h1 ((class "page_header")) "Foo 2.0!"))
>        (current-page-style-sheet " http://localhost/stylesheet.css")
>        (define (html-a-page)
>          (html-page #:body  "Foo bar baz"))
>     where html-page is defined "html.scm". 
> For a given site, I typically wrap the 'start' procedure in the 
> site-wide defaults:
> (define (start ir)
>  (parameterize ([current-page-title "Foo 2.0"])
>   (html-a-page)))
> Parameters will work in the web-server provided you are only using 
> 'parameterize', but not if you are using the parameter-procedure set method.
> I think this approach is most what you want, as cells do something 
> different, and your `persistent parameters' seem very kludgy

Yeah, I am not too happy happy about them either.

The usage of parameterize in start does do what I want - it's just
that it seems cleaner to define the default values where they "belong".

That is, what I want, I think, is a

    (define-default property value)

form, which can be used anywhere. To use the defaults it would be ok
to write

    (define (start initial-request)

Furthermore if module A requires B, which requires C, then defaults
in C can be overruled by defaults in B.

Hmm. It sounds as if this a compile-time issue and could be
solved by using macros.

Jens Axel Søgaard

Posted on the users mailing list.