Configurable syntax
bearophile
bearophileHUGS at lycos.com
Fri May 22 15:07:10 PDT 2009
Jason House:
> I'd love to see compile-time functions returning types.<
Glad to see my post appreciated :-)
>IMHO, it's far superior to the template-based approach.<
Even if such compile-time functions can't fully replace templates (so templates can't be removed from the language) such functions may be a significant improvement anyway. I have shown some examples in another post.
But for some of those functions you may enjoy having a "static while" too :-)
Probably you can even write things like:
auto foo(type T) {
static if (T == int)
return 1;
else
return T[];
}
>it's possible for templates to define an instance with unknown type and value. A non-templated function returning either a type or value can't do that.<
Can you explain better or show an example?
Bye,
bearophile
More information about the Digitalmars-d
mailing list