Concept proposal: Safely catching error

Jesse Phillips via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 8 11:33:21 PDT 2017


I want to start by stating that the discussion around being able 
to throw Error from nothrow functions and the compiler 
optimizations that follow is important to the thoughts below.

The other aspect of array bounds checking is that those 
particular checks will not be added in -release. There has been 
much discussion around this already and I do recall that the 
solution was that @safe code will retain the array bounds checks 
(I'm not sure if contracts was included in this). Thus if using 
-release and @safe you'd be able to rely on having an Error to 
catch.

Now it might make sense for @safe code to throw an 
ArrayOutOfBounds Exception, but that would mean the function 
couldn't be marked as nothrow if array indexing is used. This is 
probably a terrible idea, but @safe nothrow functions could throw 
ArrayIndexError while @safe could throw ArrayIndexException. It 
would really suck that adding nothrow would change the semantics 
silently.


More information about the Digitalmars-d mailing list