shorthand template and static conditionals?
Daniel Keep
daniel.keep.lists at gmail.com
Wed Jul 29 18:49:44 PDT 2009
Jeremie Pelletier wrote:
> Could it be a valid option to have a shorthand template syntax if the template body has only one statement? Something like:
>
> template Tuple(A...) alias Tuple = A;
Aside from that not being how alias works,
template Tuple(A...) alias A Tuple;
template Tuple(A...) { alias A Tuple; }
You're saving two characters; hardly seems worth it, to me. That said,
I can't think of any technical reason why you couldn't change the
grammar to allow for a single declaration.
> Another suggestion would be to have the ?: syntax supported for static statements, as we're currently forced to use static ifs. It really adds a lot of code to templates for even simple conditions.
I don't think using ?: for statements is a good idea; it's only ever
suitable for very small expressions.
The problem there is that there would be no way to distinguish between a
compile-time ?: and a run-time ?: for either the compiler or the
programmer. I have enough grief with CTFE and kinda-static foreach, I
don't want to see another construct like that added.
More information about the Digitalmars-d
mailing list