This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: Kawa Servlets
- To: per at bothner dot com
- Subject: Re: Kawa Servlets
- From: "Nic Ferrier" <nferrier at tapsellferrier dot co dot uk>
- Date: Fri, 10 Mar 2000 22:46:28 +0000
- Cc: kawa at sourceware dot cygnus dot com
>>> Per Bothner <per@bothner.com> 10-Mar-00 9:25:45 PM >>>
>I would do no-arg constructors first. We could handle
>constructors perhaps with a `define-constructor' declaration.
Possibly...
>* The module syntax, which uses key-words like `define' to
>declare fields and methods. A Scheme source file implicitly
>defines a class, but we may also add an explicit `module'
>keyword to allow nested module-style class definitions.
>* The `object' and `define-class' forms, where the `define'
>keywords are implied by the syntax. These can be nested
>inside other "bodies".
The second option is more "schemey" isn't it?
>For the module-style syntax, what do people think of the following?
>(module-name <CLASSNAME>)
>(module-extends <CLASS>)
>(module-implements <INTERFACE> ...)
This is pretty good I think... what is Guile's system?
Is it much different from either of these?
>As an example:
>(module-name <p.foo>)
>(module-extends <javax.servlet.http.HttpServlet>)
>(define (doGet (req :: <javax.servlet.http.HttpServletRequest)
> (res :: <javax.servlet.http.HttpServletResponse))
> #!void
> ...)
Ca Marche!
It would be good if it was easy to write such things in pure Scheme
without the need to refer to low-level Java implementations.
That's why I was looking at having a SchemeServlet.class written in
Java which would act as the call point for some Scheme definition of
what a servlet (a "schemlet") is. Or even a SchemeReadyServletContext
which allowed schemlets to be loaded alongside vanilla servlets.
>Better would be:
>(define (doGet (req res)
> ...)
This is better... as long as it's possible to write schemey wrappers
for request response.
ie instead of:
(define (doget request response)
(invoke request 'get-path-info))
I could write:
(define (doget request response)
(request 'path-info))
This could be implemented like this:
(module-name <p.foo>)
(module-extends <javax.servlet.HttpServlet>)
(define (doGet (req :: <javax.servlet.http.HttpServletRequest)
(res :: <javax.servlet.http.HttpServletResponse))
#!void
(let ((request (make-some-scheme-request-object req))
(response (make-some-scheme-response-object resp)))
(do-get request response)))
But how would we get the defintion for the do-get procedure in there?
Could a Kawa module be declared abstract?
>I also think it makes sense to have a special servlet class
>that has a one-argument doGet method, that returns a "result
value";
>the value of that result is then sent as the response.
I agree. That would be a very usefull short cut.
*Servlet*
A related idea would be a defintion which would cause top-level
evaluations to be output to the port as they occur. A suppresion form
would be required,
eg:
(define (do-get request response)
(servlet-name) ;;gets output on eval
;;outputs "my-param" then all the parameter names
(cons "my-param" (request 'parameter-names)))
I suppose that this would need an alternate define - one that mapped
output statements into the body form.
Perhaps (define-servlet () ...)?
Is this a bad idea or a good idea?
*Related module system question*
The following has just occured to me and I point it out in case Per
and others haven't spotted it yet (though I'm sure they have).
Is compilation of a Scheme module which extends an abstract class but
does not implement the required methods legal? Will the compiler
complain? (the resulting .class would be legal)
Nic