This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: feedback on KRL
Hoehle, Joerg-Cyril wrote:
1) Trying to still use .scm libraries
My setup typically involves a huge sitedefs.scm (or rather, a sitedefs full of load "xyz") and small .brl pages.
Using KRL, I recognize that it automatically converts .krl to .class files.
But what would happen to something equivalent to the sitedefs.scm file?
I can put
(require <gnu.brl.stringfun>)
inside a .krl file and use e.g. brl-string.
What I mean is that I fear that I'll have to turn my libraries into .class files. That's a burden IMHO -- during development.
If I just write
(load "foo.scm")
inside a .krl file, it gets reloaded for every access -- doesn't it?
Yes. A possible work-around:
(define-constant foo (load "foo.scm"))
This should (I think) cause foo to be evaluated at class init time,
though I haven't verified that it works. If you modify foo.scm, you
need to modify the .krl file.
This might also work, but I make no guarantees:
(require <foo.scm>)
or
(require <foo>)
I don't want that. I wish for something to be able to load .scm files just once, like brl does with sitedefs, and with all files loaded from sitedefs as a consequence, until the servlet eventually dies because of inactivity.
Ok, maybe I should make more use of file-compilation (better type inference etc.), then I could use require. Yet I'd appreciate that as an option, not an obligation.
I also appreciate that the kawa file compiler gives more/better warnings than a simple LOAD.
Yes. Partly it's a matter of specifying the semantics - what if there
are multiple instances of the same servlet? What about multiple
servlets sharing the same Kawa environment? Presuambly mutiple
servlets in the same "web application" should share the same Kawa
environment *and* the set of "required" classes, including sitsdefs.scm.
2) Trying to print something from within a subroutine
Since my setup typically involves SXML, X|HT|ML generation occurs inside Oleg's SRV:send-reply calls, which calls display or another function of mine.
However, this currently generates no output in KRL.
My guess is this guess to the catalina "output" file, which you can
find among the other Tomcat log files. KRL doesn't redirect
output like BRL does. It probably should.
The fix (I assume) is to replace the
proc.apply(ctx);
in KawaPageServlet's apply method by:
OutPort out = new OutPort(response.getOutputStream());
OutPort save = OutPort.outDefault();
try
{
OutPort.setDefault(out);
proc.apply(ctx);
}
finally
{
OutPort.setDefault(save);
}
This has a couple of problems:
(1) OutPort.setDefault sets the global default output port,
unless the current thread is a Future. Better would to
set a per-thread variable, but that requires more substantial
changes.
(2) It might be cleaner if the ServletPrinter used for the expression
results were an OutPort that we can use directly for display/write, but
that also requires some re-work.
So how can I have output generated from deep within a subroutine or library?
With BRL, I pass (lambda (x) (brl x)) to the libraries, so they can perform output.
At the very least, the brl function/macro should be made to work.
--
--Per Bothner
per@bothner.com http://per.bothner.com/