« Return to Thread: Towards a revised collection API

Re: Towards a revised collection API

by David MacIver :: Rate this Message:

Reply to Author | View in Thread

On Fri, Apr 18, 2008 at 5:53 PM, Jamie Webb <j@...> wrote:

>
> 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.

I don't buy that. It's a sufficiently rare error that breaking the
performance of this feature so totally in an attempt to make debugging
of the it slightly easier is really pointless.

In any case, if this is really deemed to be a problem there are
solutions of varying degrees of difficulty  The easiest it to have a
global debug parameter somewhere that can be set and have the stack
trace be suppressed only if this isn't set.

 « Return to Thread: Towards a revised collection API