Proposal: static template(fail)

Janice Caron caron800 at googlemail.com
Thu Dec 13 23:28:52 PST 2007


On 12/14/07, Jason House <jason.james.house at gmail.com> wrote:
> I've always been under the impression that use of static if is the "D way".

It's a choice. It happens to be my /preferred/ choice, but the
multiple-templates way still needs to be supported.


> if there's a chance the programmer (or
> more likely, a later code maintainer) can get confused, then I think it's
> better to err on the side of rigorous compile-time errors.

None of which changes the fact that, as I keep stressing, IT'S NOT AN
ERROR to fail to match. One should not be forced to generate an error,
when there plainly isn't one.

Even if you /only/ use the static if style, and there are no
alternative overloads, at the end of your chain of static ifs, you
still want to be able so say static template(fail) (or whatever syntax
is deemed right), rather than static assert, because if the template
can't be instantiated at all, yes there's an error /somewhere/ -- but
it's not in the template code; it's in the calling code - and that's
the only place an error should be reported.



More information about the Digitalmars-d mailing list