Let's improve D's exceptions

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu May 14 05:38:33 PDT 2015


On Thursday, 14 May 2015 at 10:24:45 UTC, Ola Fosheim Grøstad 
wrote:
> Using alias like this makes code hard to read. Error types 
> should be humanly deducible at the failure site.

Perhaps, I don't hate it too much here though because the alias 
is fairly local.  Without it, you'd probably write 
enforce!(BaseClass, fopen)("file", "rb") to get the thing I was 
going for.

> You'd be better off having non-ignorable result types (e.g. 
> tagged union/variant/algebraic) and a typed way to turn those 
> into exceptions.

The only place where I'd be interested in using something like 
this is calling F functions and you can't change their signature 
too much...


More information about the Digitalmars-d mailing list