|
From: Timothy J. H. <ti...@cs...> - 2004-08-10 20:36:44
|
On Aug 10, 2004, at 3:14 PM, Ken Anderson wrote:
> Tim,
> Your documentation mentions that a init.scm file is loaded the first
> time a .servlet is executed.
> How should a servlet that needs to load code do it so it only happens
> once?
One way is to use the (use-module "FILE.scm") command
but we need to make a (reload-module "FILE.scm") command that can be
used in development....
>
> Also, since all servlets run in the same environment, won't your
> students potentially have name conflicts, at least potentially?
This is true, but I view it as a feature and not a bug.
The idea is to have the student's append their initials or login id to
all their globally defined names
(e.g. (define (tjh-webpage TITLE CSS BODY) ......) )
then the students can load each others code and use each other's
procedures ...
We could also have students use the
(use-module "FILE.scm" 'import 'all "PREFIX:")
or (reload-module "FILE.scm" 'import 'all "PREFIX:")
approach to load in their code with a prefix..... This keeps the
FILE.scm code simple
and still allows the libraries to be used without much interference...
This can be used to encourage a community of reuse. Student's in the
summer course
thought it was very cool that they could all use everyone else
procedures ....
I do need a way for them to reset the primitives, because last summer
someone
wrote a servlet that started with
(set! define 5)
which wiped out the real defintion of define!!
Another possibility would be to create a global hashtable H of
jscheme.JScheme instances
and have a macro that looked up the SchemeEvaluator in which to
evaluate the servlet...
For example,
(use-context
"tjh"
(use-module "mydefs.scm" 'import 'all)
...
(servlet (a b c)
BODY
)
)
would lookup the context (a jscheme.JScheme. instance)
with key "tjh" (or create one if it doesn't exist), and then
evaluate the servlet in that context. Does this seem like
a reasonable approach??
---Tim---
>
> k
>
|