Strange Loop 2012

Philippe Sigaud philippe.sigaud at gmail.com
Wed Oct 17 05:40:03 PDT 2012


On Wed, Oct 17, 2012 at 4:54 AM, bearophile <bearophileHUGS at lycos.com> wrote:
>>
>> https://raw.github.com/psnively/types_vs_tests/master/src/main/scala/Shapeless.scala
>
>
> If this is equivalent, then in D it was too much easy:

Why not use integral template parameters directly? And checking if all
params are between 0 and 9, of course. The user syntax would then be
cleaner:

void main() {
    static assert(!isValid!(0, 1)());
    static assert( isValid!(3, 4, 5, 8, 8, 2, 8, 6, 5)());
    static assert( isValid!(1, 2, 3, 4, 5, 6, 7, 8, 9)());
}

And, of course, there is no need for templates at all. A standard,
compile-time interpreted function could do it for you:

void main() {
    static assert(!isValid(0, 1));
    static assert( isValid(3, 4, 5, 8, 8, 2, 8, 6, 5));
    static assert( isValid(1, 2, 3, 4, 5, 6, 7, 8, 9));
}


More information about the Digitalmars-d mailing list