Lazy template arguments?
bearophile
bearophileHUGS at lycos.com
Sun Jan 13 04:30:57 PST 2013
monarch_dodra:
> Is this proposal a pure optimization trick, or is there some
> functionality gains here. The only one I can think of, is if
> "Foo!B" would fail to compile. Is this what you are going
> for...?
It's first of all a way to implement a Ternary in library code,
because in some situations instantiating a template causes an
error, so the lazyness is needed to avoid those errors, and
instantiate only the correct branch/argument. If this feature
also reduces the compilation time a bit, then it's welcome :-)
Beside implementing a Ternary, do you see other usages for such
lazy template arguments?
> Also:
> //----
> template Ternary(bool b, T1, lazy T2) {
> //----
> While is only T2 lazy?
My mistake, both of those arguments are better to be lazy:
template Ternary(bool b, lazy T1, lazy T2) {...}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list