I know how to fix interactions templates now

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Oct 1 17:31:54 UTC 2020


On Thu, Oct 01, 2020 at 07:39:04AM +0000, FeepingCreature via Digitalmars-d wrote:
[...]
> Right now, constraints are carried forward invisibly through gagged
> template instantiation via __traits(compiles). Miscompilation *itself*
> becomes the propagated constraint failure, which is of course
> horrible.
> 
> This is why I want __traits(canInstantiate), so we can at least
> *enforce* that constraints are manually carried forward by the
> programmer. If a template passes its constraints, it should also pass
> semantic2/3 in full. It should never be necessary to gag errors after
> the constraints.
> 
> Body SFINAE is cancer.

This.  I've spent who knows how many hours trying to decipher template
errors precisely because a single misspelled identifier in the wrong
place can completely change the chain of template instantiations,
leading to a completely unrelated failure in a completely unrelated part
of the code, with the original real error gagged so there is almost no
clue is to what the problem really is.

I wish there were a better mechanism of deferring to a different
template besides all-out error gagging regardless of the nature of the
error.  It's one thing to try a different overload when sig constraints
fail; it's a whole 'nother can o' worms when sig constraints pass but a
typo causes the body to fail.  The worst is when this was triggered from
within another function's sig constraints -- then you really have almost
no way to trace the source of the error.


T

-- 
There is no gravity. The earth sucks.


More information about the Digitalmars-d mailing list