[plt-scheme] Re: Shared resources for servlets

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Tue Sep 9 14:11:57 EDT 2003

Keith Frost wrote:
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> If I'm not mistaken, you've answered your own question:  just use a
> module. When subsequent servlets 'require' the same module, it is not
> reloaded, and
> any local state in the module is preserved.

I don't think so...

Basically I have a module A that I want each servlet to have access to the
bindings of.  The body of A has expressions evaluated for side-effects that I
want to evaluate only once, when the server is started (or the first servlet
is loaded).

If B and C are servlets that require A, the side-effects are produced when B
is loaded and again when C is loaded.

;; a.ss
(module a mzscheme
  (printf "side-effect of A\n"))

;; b.ss
(module b mzscheme
  (require "a.ss")
  (provide interface-version timeout start)
  (define interface-version 'v1)
  (define timeout +inf.0)

  ; start : request -> response
  (define (start initial-request)
    `(html (body (p "loaded")))))

;; c.ss -- same as b

This prints two "side-effect of A"s.

I feel like I'm totally missing the broad side of a barn here.  Thanks for the
help.

-d



Posted on the users mailing list.