On the subject of error messages
Stanislav Blinov via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 16 04:20:57 PDT 2017
On Tuesday, 16 May 2017 at 09:04:32 UTC, Nick Treleaven wrote:
> ...
>>> foreach(i, T; types!args) {
>
> typeof(args) ;-)
Thanks :)
>>> static if (is(T == string)) {
>>> pragma(msg, format!"Argument %d is a string, which
>>> is not supported"
>>> (i+1));
>
> The problem with this approach is all the work required to
> convert existing code to use this style. Breaking the binary
> ops of the constraint into parts and reporting which failed (as
> the other replies mention) already would work with existing
> code, even if your approach can allow better messages. The
> binary ops part would immediately bring a huge improvement,
> despite any deficiencies.
That's not a problem. In cases where compiler-provided diagnostic
is sufficient, nothing will need to be done.
>
> I think we should allow inline constraints*, non-inline
> constraints can still be used/combined. Inline constraints are
> easier to read and relate to what they affect, allowing any
> non-inline constraint to be considered as something with a
> wider scope (i.e., multiple arguments).
No matter if it's inline or trailing, it needs way, *way* better
reporting than what we have now, so if you were to prioritize,
which one would you solve first? :)
More information about the Digitalmars-d
mailing list