scope() statements and return
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 5 17:29:18 PDT 2014
On Sunday, 5 October 2014 at 16:30:47 UTC, Ola Fosheim Grøstad
wrote:
> On Sunday, 5 October 2014 at 15:03:08 UTC, ketmar via
> Digitalmars-d wrote:
>> so Error should not be catchable and should crash immidiately,
>> without
>> any unwinding. as long as Errors are just another kind of
>> exception,
>> the promise must be kept.
>
> I find it strange if you cannot recover from
> out-of-memory-error. The common trick is to preallocate a bulk
> of memory, then free it when you throw the out of memory
> exception so that you can unwind. When destroying the
> out-of-memory-object you need to reallocate the bulk of memory.
>
I know of several cases where this trick was used and it turned
out horribly wrong. OOE is NOT recoverable. It may be in some
cases, and you can use trick to make them recoverable in more
cases, like the one mentioned, but ultimately, you have no
guarantee, and worse, no way to know if you are in a recoverable
situation or not.
The only valid use case i know of to catch this kind of error is
at top level to return various error code. Even logging may be
broken at this point.
More information about the Digitalmars-d
mailing list