[racket-dev] #:namespace

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

That's not how the #:namespace argument ever worked.

#:namespace takes a list of module names that are shared between the
server and the servlets.

In the case of the command-line tool, this is effectively a way to
make some modules shared between different servlets, through the
common party of the server.

Since those servlet modules haven't been run, there's no confusing
because they've always been evaluated in the same namespace.

In contrast, web-server/insta, serve/servlet, and dispatch/servlet all
take a closure rather than a module name as the servlet. This closure
must have come from some namespace and it causes weird, unexpected
behavior to not allow it to use the same namespace it came from when
it runs.

Basically, the addition of the #:namespace argument in the first place
was just a knee-jerk reaction on my part making dispatch/servlet do
everything that dispatch-servlets does without really thinking through
whether it needed/made sense to have each feature.

Jay

On Mon, Oct 4, 2010 at 7:41 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> It sounds like one could work around this by taking whatever was
> passed to #:namespace and making the servlets move over to that
> namespace, at least.
>
> Robby
>
> On Mon, Oct 4, 2010 at 8:28 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> 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
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/dev
>>
>



-- 
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.