This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Additional constructs in gnu.expr
- To: Daniel Bonniot <Daniel dot Bonniot at inria dot fr>
- Subject: Re: Additional constructs in gnu.expr
- From: Per Bothner <per at bothner dot com>
- Date: Wed, 26 Sep 2001 16:14:14 -0700
- CC: kawa at sources dot redhat dot com
- References: <3BB20A57.65236DE3@inria.fr>
Daniel Bonniot wrote:
>gnu.expr currently holds classes to generate code for functional
>languages a la Scheme. As a part of my Nice compiler
>(http://nice.sourceforge.net) if have written a few expression classes
>to generate code for some imperative features: for and while loops, pre
>and post incrementation of variables (a la 'x++'), lauching an
>exception.
>
All of these are in Kawa-Scheme. However, they are represented
using existing Expression forms. Loops are translated into tail-recursive
functions (which get inlined and thus compiled into loops). Launching an
exception is compiled into a function allocation (ApplyExp where the
function
is a throw_name Procedure). An increment can be represented using a SetExpr
(if a variable is incremented), or an ApplyExp (if a field or array
element is
incremented).
>I was carefull to make them generate reasonably good bytecode.
>
The existing implementations also generate reasonably good bytecode.
What about the various ExpWalker classes? That is my main reason for
trying to avoid new Expression classes.
>My question: do they belong to gnu.expr, or should I place them in a
>personal package? I think they could be useful to people using gnu.expr
>to generate java bytecode for other imperative languages.
>
If you add a new (say ForExpr) class that (say) FindCapturedVars does not
know about, then things will almost certainly break.
Building a loop isn't that difficult. See the makeWhile helper method in
Expression. The actual API to makeWhile is awkward, and needs some
re-thinking,
because there are scoping issues involved, at least if its a for loop.
I think better is some convenience methods and/or documentation to make
it easier to construct loops etc. But I don't think creating new
Expression classes
is needed.