D's greatest mistakes

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Nov 29 04:29:49 PST 2010


On 11/29/10, bearophile <bearophileHUGS at lycos.com> wrote:
>> * Template pattern matching is incomplete
>
> I don't understand this, please explain better. But I think the syntax of
> is() is awful and I'd like to shoot it.
>

+1. I'd prefer if we had a constraint block of some kind. I mean we
already have in/out contracts which look very nice:

void somefunc()
in
{
    // ...contract preconditions...
}
out (result)
{
    // ...contract postconditions...
}
body
{
    // ...code...
}

Why not do the same for templates? Something like this:

void foo(A, B, C)(A a, B b, C c)
constraint
{
    isDynamicArray(a);
    isIterable(a);

}
body
{
    ...
}


More information about the Digitalmars-d mailing list