Bragging about Unix and D
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Thu Aug 24 14:58:37 PDT 2006
Oskar Linde wrote:
> Sean Kelly wrote:
>> Tom S wrote:
>>>
>>> template table(int i = 0) {
>>> pragma (msg, row!(i));
>>>
>>> static if (i+1 < height) {
>>> mixin .table!(i+1) table;
>>> } else {
>>> alias void table;
>>> }
>>> }
>>
>> Huh, now there's a use for mixin I can appreciate. Nice work.
>
> but s/mixin/alias/ will work just as well. :)
Here it does, but in the general case it doesn't work as well. First
since the mixin creates a (unique) new template instance, that might
differ significantly if such template has run-time members. Second, you
can't use a mixin in an instruction block, and an alias can (and I've
used that).
So that's not a good use for mixin, use alias for instantiating dummy
template instances. :)
Also the
... else {
alias void table;
}
is not necessary. ;)
More information about the Digitalmars-d
mailing list