Propagating Errors
Nicholas Wilson
iamthewilsonator at hotmail.com
Fri Mar 8 06:09:30 UTC 2019
On Wednesday, 6 March 2019 at 12:48:08 UTC, FeepingCreature wrote:
> Personally, I think the problem comes down to this: we have no
> way of propagating errors from inside template constraints to
> the user.
>
> I think the way to go is instead of returning `false`, have
> __traits(compiles) (which is really the core source of these
> difficulties)
I find `is` expressions to be more to blame, but the underlying
reason is the same: the error are gagged. This is good most of
the time (because otherwise it would be like always using
verrors=spec), but it misses the small fraction of the time when
that is extremely useful.
> return an "error object" that evaluates to false, but also
> encodes additional information about the problem, recursively.
>
> Propagate this through short-circuiting - ErrorObject && bla =
> true, bla && ErrorObject = ErrorObject, etc.
>
> The compiler can then pick up on the fact that an error object
> was the reason why a template constraint failed to give a
> highly informative error message.
>
> For instance:
> *snip*
This works nicely for __traits compiles, I'm not so sure about is
expressions (though I'd love to be shown otherwise).
More information about the Digitalmars-d
mailing list