DIP76: Autodecode Should Not Throw

w0rp via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 7 00:42:00 PDT 2015


On Tuesday, 7 April 2015 at 04:05:38 UTC, Vladimir Panteleev 
wrote:
> On Tuesday, 7 April 2015 at 03:17:26 UTC, Walter Bright wrote:
>> http://wiki.dlang.org/DIP76
>
> I am against this. It can lead to silent irreversible data 
> corruption.

I can see the value in both.

With something like Objective C on iOS, basically everything is 
nothrow. They don't do any cleanup for references when exceptions 
happen, so they don't generate slower reference counting code. 
Exceptions in Objective C on iOS are not supposed to be caught 
ever. So you don't use exceptions and garbage collection, your 
code runs pretty fast, and your applications are smooth.

On the other hand, not throwing the exceptions leads to silent 
failures, which can lead to creating garbage data. Objective C in 
particular is designed to tolerate failure, given that messages 
run on nil objects simply do nothing and return cast(T) 0 for the 
message's return type. You're in a world of checking return 
codes, validating data, etc.

Maybe autodecoding could throw an Error (No 'new' allowed) when 
debug mode is on, and use replacement characters in release mode. 
I haven't thought it through, but that's an idea.


More information about the Digitalmars-d mailing list