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: tagbody


When Kawa supports full continuations it will not be using
exceptions, but it will still have performance costs.  (The
costs of invoking a continuation will be much less than
throwing an exception, but there will be general overheads.)

The cleanest general solution is I think as Bruce says to
use a bunch of mutually recursive functions defined using
letrec.  This is in principle quite efficient.  You would
need to specify --full-tailcalls to avoid recursive calls.
Even without --full-tailcalls Kawa does optimize simple
tail-recursion (self-tail-calls), but doesn't optimize
mutually recursive tail-calling procedures.  This would
be nice to have implemented, and shouldn't be that difficult.
We need to identify a "tail-call set":  A set of functions
that are only called at known places, and (except for one
"entry" call) are only called via tail-calls from other
functions in that set.  In that case the functions can
be inlined, and all the calls replaced by gotos.

Another option is to add a new Expression sub-type that handles
statements with labels and goto.  However, this isn't any more
expresive than the mutually recursive functions, so I don't
think it is worthwhile.

If your current implementation uses try/catch/throw and that
works, then it might be worthwhile trying to Kawa so it can
optimize that idiom to BlockExp/ExitExp.

Notice how gnu/kawa/slib/srfi1.scm uses continuations to
exit loops.  Also note the comment that a "good compiler"
should optimize this.  Alas, Kawa doesn't, yet.  If so,
it would use BlockExp/ExitExp.
--
	--Per Bothner
per at bothner dot com   http://per.bothner.com/



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