[racket-dev] #:namespace

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Oct 4 09:28:49 EDT 2010

I didn't realize the handin server used it when I removed it.

It definitely doesn't need it.

The #:namespace argument made it so the closure given as the request
handler was called in a different namespace than it was evaluated in,
causing a reinstantiation of the module and other weirdness. For
example,

#lang web-server/insta
(require (only-in "some-stateful-module.rkt" set-a! unbox-a))
; where a defaults to "Hello World"
(set-a! "Hello World, not")
(define (start req)
 (unbox-a))

would evaluate to "Hello World" instead of "Hello World, not", because
some-stateful-module was not shared with the new namespace. This seems
incredibly wrong, so I removed the namespace argument and the request
handler closure is simply evaluated in the namespace it came from.

The #:namespace argument is still useful for other servlets that come
from serve/servlet, because they are loaded from disk and may need to
share some modules with the main one, but should otherwise be
isolated.

Jay

On Mon, Oct 4, 2010 at 5:56 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> Probably there was some mail on this topic, but...
>
> Why did `dispatch/servlet' lose its `#:namespace' argument?
>
> The handin server was using that argument, so it no longer runs.
>
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the dev mailing list.