This is the mail archive of the kawa@sources.redhat.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]
Other format: [Raw text]

how smart is compilation?



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, eg:

  some text &(+ 5 1) which has &(begin '(1 2 3 4 5)) some expressions

might become:

  (define s `("some text " 
	      (lambda () (+ 5 1))
	      "which has "
	      (lambda () (begin '(1 2 3 4 5)))
	      "some expressions"))

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? 

If I define them on the top level I guess they would just be methods?
For example:

  (define (one)
    (+ 5 1))

  (define (two)
    (begin '(1 2 3 4 5)))

  (define s `("some text" ,one "which has " ,two "some expressions")


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.


Nic


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