change mixins
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Feb 14 15:28:38 PST 2010
Denis Koroskin wrote:
> On Mon, 15 Feb 2010 00:31:29 +0300, Walter Bright
> <newshound1 at digitalmars.com> wrote:
>
>> Right now, mixins are defined and used as:
>>
>> template foo(T) { declarations... }
>>
>> mixin foo!(int) handle;
>>
>> The proposal is to switch it around:
>>
>> mixin template foo(T) { declarations... }
>>
>> foo!(int) handle;
>>
>> to follow the notion that mixin templates are very different from
>> regular templates, and that should be reflected in their definition
>> rather than use.
>>
>> What do you think?
>
> I support the change, expect that I believe mixing in the mixin template
> should involve the "mixin" keyword.
[snip previous proposal]
The hope with the proposed change is to leverage existing mixin
implementation into a solid and useful facility that could actually
obviate the need for macros. I reckon there is a lot of value in the
current mixin template idea, but it's just packaged the wrong way.
Requiring mixin on the call side (something that many have complained
about) would, in my opinion, keep the feature packaged the wrong way.
As an example of where we want to take this, consider an interpolation
facility. The expression:
interp!"a = $a and b = $b\n"
expands into:
"a = ", a, " and b = ", b, "\n"
which you can writeln, pass to text or whatnot.
Andrei
More information about the Digitalmars-d
mailing list