[LLVMdev] Iterator protocols

me22 me22.ca at gmail.com
Tue May 13 19:09:30 PDT 2008


On Mon, May 12, 2008 at 9:49 PM, Talin <viridia at gmail.com> wrote:
>  So the question is, what's the trade-off. In most languages that support
>  exceptions, you tend to think of exceptions as expensive operations that
>  should only be thrown if something truly "exceptional" happens. OTOH,
>  the Java case is also made worse by the fact that a large part of the
>  time you'll be using the more expensive interface dispatching, rather
>  than simple vtable dispatching.
>

I really like the idea of the (apparently possible, if uncommon)
implementation of (C++) exceptions that means no overhead at all in
the normal path, but with a somewhat expensive throw.

There's something quite satisfying about exceptions being able to
actually make code faster (since it can get rid of the checks on
return values).

But even with that an expensive throw, exceptions can still be the
fastest way to exit a deep (non-tail) recursion (with no non-trivial
local scope destructors).

And yes, reaching the end of an iterator range does not seem to me
like a good use for exceptions.

YMMV, of course.



More information about the llvm-dev mailing list