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]

Re: Question on compiling to bytecode


Daniel Bonniot wrote:
Doesn't Kawa also have an interpreter that duplicates the compiler logic? That is, each construct in gnu.expr has both a compile and an eval method, with (hopefully) identical semantics?
No.  Each construct has a compile method, but only the simple
constructs (variable reference, assignment, constant, function
call) have a non-exception-raising eval method.  If any of the
more complex expressions (inluding let-binding and lambda
expressions) are seen, that forces compilation to happen.

The idea is that simple expressions are probably most common
in interactive use, and it is easy to interpret them, so we
might as well, to avoid the (modest) overhead of compilation.
But more complex expressions, including any that create
lexical bindings, would be more complicated to interpret,
and would require duplicate machinary to interpret it (e.g.
setting up the data structures for lexical bindings), so
it is simpler to just invoke the compiler in that case,
given that the compiler overhead *is* fairly modest.  It
also helps ensure that behavior is consistent.
--
	--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]