June 12, 2005 Implicit Template Properties and Mixins | ||||
---|---|---|---|---|
| ||||
As stated in template.html, "If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation", could this be expanded to also apply to a mixin's MixinIdentifier? Such as: template MixFoo(T, T VALUE = T.init) { T MixFoo = VALUE; } int main() { mixin MixFoo!(int, 3) mfoo; printf("%d\n", mfoo); // Instead of mfoo.MixFoo. Prints 3. return 0; } So that mfoo is treated as type T (int) instead of a mixin, since MixFoo is the only member in the template and has the same name. I think this will add much eloquence. |
June 13, 2005 Re: Implicit Template Properties and Mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | I also tried that before. FWIW, I agree with you, it would add much eloquence and allow a certain (very) restricted form of macros to D.
"Vathix" <vathix@dprogramming.com> wrote in message news:op.sr9p27m0kcck4r@esi...
> As stated in template.html, "If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation", could this be expanded to also apply to a mixin's MixinIdentifier? Such as:
>
>
> template MixFoo(T, T VALUE = T.init)
> {
> T MixFoo = VALUE;
> }
>
> int main()
> {
> mixin MixFoo!(int, 3) mfoo;
> printf("%d\n", mfoo); // Instead of mfoo.MixFoo. Prints 3.
> return 0;
> }
>
>
> So that mfoo is treated as type T (int) instead of a mixin, since MixFoo is the only member in the template and has the same name. I think this will add much eloquence.
|
Copyright © 1999-2021 by the D Language Foundation