« Return to Thread: Towards a revised collection API

Re: Towards a revised collection API

by Jamie Webb-2 :: Rate this Message:

Reply to Author | View in Thread

On 2008-04-18 13:53:20 David MacIver wrote:

> On Fri, Apr 18, 2008 at 1:28 PM, David MacIver
> <david.maciver@...> wrote:
> >  >  Non-local returns are implemented via exceptions, so they are
> >  > not really efficient. I think any move away from iterators is
> >  > likely to imply a performance loss.
> >
> >  I disagree. Exceptions are extremely fast on the JVM and have been
> > for years. They basically compile to gotos. It's just stack trace
> >  generation which is slow, which you can surpress in your
> >  implementation of Throwable (which I assume Scala's non-local
> > returns do. If not, I'd consider that a bug. I'll check later).
>
> Looks like it doesn't. I've filed a bug:
> https://lampsvn.epfl.ch/trac/scala/ticket/775

There's a reason: if a closure escapes its defining method then the
exception will propagated as normal. This would be a pain to track down
without a stack trace.

/J

 « Return to Thread: Towards a revised collection API