assume, assert, enforce, @safe

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 18:27:56 PDT 2014


On 7/31/2014 2:01 PM, ponce wrote:
> This also puzzles me. There is the point where the two types of errors blend to
> the point of being uncomfortable.
>
> Eg: a program generates files in X format and can also read them with a X
> parser. Its X parser will only ever read output generated by itself. Should
> input errors in X parser be checked with assert or exceptions?

Exceptions. Although there are grey areas, this is not one. Filesystems are 
subject to all kinds of failures, exhaustions, modification by other processes, 
etc., which are not logic bugs in your program.


If you're brave and want to have some fun, fill up your hard disk so it is 
nearly full. Now run your favorite programs that read and write files. Sit back 
and watch the crazy results (far too many programs assume that writes succeed). 
Operating systems also behave erratically in this scenario, hence the 'brave' 
suggestion.



More information about the Digitalmars-d mailing list