Better error messages - from reddit
Meta
jared771 at gmail.com
Mon Mar 4 18:42:45 UTC 2019
On Monday, 4 March 2019 at 16:49:25 UTC, Sebastiaan Koppe wrote:
> 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?
I think that's a little drastic. Template constraints are far
more powerful than Rust traits or Swift protocols.
I agree, though, that their design makes it much harder to give
good error messages.
More information about the Digitalmars-d
mailing list