Better error messages - from reddit
Sebastiaan Koppe
mail at skoppe.eu
Mon Mar 4 16:49:25 UTC 2019
On Monday, 4 March 2019 at 15:47:12 UTC, H. S. Teoh wrote:
> This is why I'm starting to think sig constraints are not the
> genius idea they first appeared to be. The basic problem is
> that when you write a sig constraint, you're basically saying
> "I only accept template arguments if they don't cause an error,
> otherwise it's not my problem and somebody else can pick up the
> tab", whereas the essence of user-friendly error-reporting is
> "I accept everything that looks like it ought to work, and if
> something breaks, I'll tell you why it didn't work".
It's even worse. There might be another sig constraint that is
perfectly happy. It might even be in another library. Your
function has no way to know that. Ergo, error messages are hard.
With Rust a type declares to conform to a trait explicitly. Error
messages are easy.
With D it seems we are reinventing traits, poorly. And all
because we wanted to avoid naming them?
More information about the Digitalmars-d
mailing list