This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Kawa Servlets


"Nic Ferrier" <nferrier@tapsellferrier.co.uk> writes:

> The second option [define-class, rather than implicit module] is
> more "schemey" isn't it?

Depends what you're trying to do.  For a module, it would be nice to
not have to wrap the entire source file in a define-module/define-class,
for compatibility with other Scheme's, if nothing else.

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

Guile's module system is still being discussed.  They do have
a define-class that is part of the in-progress GOOPS;  I will
try to be more-or-less compatible with that.

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

Well, we can provide syntactic sugar for servlets on top of the
"method declaration" mechanism - but that is a nice general framework.

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

Well, it is worth experimenting with different "sugars".

> ie instead of:
> 
> (define (doget request response)
>    (invoke request 'get-path-info))
> 
> I could write:
> (define (doget request response)
>   (request 'path-info))

This is the discussion about invoke.  I'm thinking  of having
something like a IndirectJavaReference class.  If X has the
type IndirectJavaReference, then (X 'foo) accesses the method or
field named foo in the class of X.  The result of (X 'foo) is
automatically wrapped in an IndirectJavaReference.  This could
be done automatically.  The trick is defining a convention so
we can know whether (X 'foo) means calling procedure X with 'foo
as an argument, or extract the field/method named foo in X.
Resolving the ambiguity can be handled using syntax, declarations,
compiler flags, or depending on the type of X.

Anyway, this is just something something I've thought about,
but haven't reached a conclusion on.  Until then, invoke
works.

> But how would we get the defintion for the do-get procedure in there?

Well, you can create IndirectJavaReference objects; just make sure
they extend gnu.mapping.NameMap.

> Could a Kawa module be declared abstract?

Perhaps.  I don't think that makes sense - at least the terminology
is off.  An abstrat module is sometimes called an interface - which
is not that different from a Java interface.

It might make sense to define an extension to support abstract
methods and (implicitly) classes.  Perhaps

(define-abstract (foo (bar :: <T>) <T> ))

or:

(define (foo (bar :: <T>) <T> (inner)))
;; Like the the Beta/Simula "inner" statement.

> *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,

This ties into two of my ideas:
* A module that evaluates to a result value.  This isn't really a
"module" (which is a set of exported bindings), but it's a "body"
whose result is a concatenations of that of the sub-forms.
* A result value given by outputing to a file/stream, rather
like a Unix shell pipe-line.  I implemented something like this
in Q.  See http://www.bothner.com/~per/software/index.html#Q
and http://home.pacbell.net/bothner/Qshell.html .

> Is this a bad idea or a good idea?

The problem we both have is too many good ideas ...
I like to implement powerful primitive ideas that can be combined
in creative ways.

> Is compilation of a Scheme module which extends an abstract class but
> does not implement the required methods legal? Will the compiler
> complain?

I'm not sure whether it should be legal.  I don't think there are any
checks currently implemented.

> (the resulting .class would be legal)

Only if the class has the abstract bit set.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]