LazyLoad

Quoting Erik V. [email protected]:

I got it. I introduced LazyException (see below) as a wrapper
for the original Exception. All methods are (once again)
delegated to the original exception with method_missing, except
for LazyException#exception.

Hmm. Interesting. I hadn’t considered making DivergenceError
delegate to its “parent” exception… I’ll have to think about
that.

Incidentally, there may be some threadsafety issues around the
exception’s backtrace array.

(Imagine two LazyExceptions in different threads getting raised
simultaneously for the same parent exception – how will the
backtraces accumulate, exactly? There may not be a problem, but I
think it bears investigation…)

-mental

(Imagine two LazyExceptions in different threads getting
raised simultaneously for the same parent exception – how
will the backtraces accumulate, exactly? There may not be a
problem, but I think it bears investigation…)

There can’t be two LazyExceptions with the same “original”
exception. The LazyException is created and stored in
Lazy@excpetion in the Mutex#synchronize block, along with
Lazy@result.

It can be thrown multiple times, concurrently, though. But
since both Exception@backtrace and LazyException@backtrace are
built when they are created (they are, aren’t they?), I don’t
see a problem.

gegroet,
Erik V. - http://www.erikveen.dds.nl/