This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: how smart is compilation?
- From: Per Bothner <per at bothner dot com>
- To: Nic Ferrier <nferrier at tf1 dot tapsellferrier dot co dot uk>
- Cc: kawa at sources dot redhat dot com
- Date: Sun, 06 Jan 2002 00:56:07 -0800
- Subject: Re: how smart is compilation?
- References: <87pu4o1iqs.fsf@tf1.tapsellferrier.co.uk>
Nic Ferrier wrote:
> I'm trying to decide how my template language experiment should be
> converted from source to executable.
>
> The output from the template pre-processor is some strings and some
> expressions all jumbled together.
>
> It seems to me that the simplest way to deal with this is to put all
> that output in a single ` quoted list with lambda forms wrapping each
> expression,
Actually, I suggest using values, and compiling with --full-tailcalls.
> eg:
> some text &(+ 5 1) which has &(begin '(1 2 3 4 5)) some expressions
You might consider using BRL's template syntax, using square brackets:
some text [(+ 5 1)] which has [(begin '(1 2 3 4 5))] some expressions
Either way, this could become:
(values "some text " (+ 5 1) " which has " (begin '(1 2 3 4 5))
" some expressions")
When compiling --full-tailcalls (whih is actually always used for
the top-level "module level") Kawa compiles values by separately
compiling each value expression, and send the result to the result.
At top-level, the result is the standard output, perhaps after some
formatting. At function level, the result is inherited from the
call context (again, assumimg --full-tailcalls).
> If I compile this to a module would it always be the case that all the
> procedures (ie: all those wrapped expressions) would get compiled to
> separate classes?
No, they should only be separate classes if they require a closure
environment. You can avoid this if you specify --module-static.
> Basically I'm trying to work out the trade off between pre-compiling
> the template (which means that you can cache the compiled class over
> invocations of some container utilizing the template but means that
> you have to check the class cache to see if you need to re-compile)
> and just evaluating it.
>
> Compilation seems simpler because there is quite a nice API for doing
> it. Efficient evaluation would be trickier (little performance hacks
> like referencing already created strings for the plain text would be
> necessary) but is probably less fuss.
I'm not sure I'm understanding what you're getting at, but my
preferene is always going to be compilation. Using eval is something
I try to discourage.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/