Alias Arguments & Expressions

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Jan 16 12:41:56 PST 2007


Xinok wrote:
>> Second, I don't really comprehend what you are trying to do with the template above... it 
>> would just be:
>> # template mul (a, b) { const mul = a * b; }
>> #
>> # void main () {
>> #   writefln(mul!(15, 30));
>> # }
> 
> a and b are typenames, not variables. You can't use aliases either since they don't accept variables:
> template mul(alias a, alias b)
> 
> The only thing that will work is a tuple:
> template mul(V...){ const mul = V[0] * V[1]; }
> And for a complex expression, that isn't very pleasing to the eye.
> 
> 
> You were right about not needing 'auto'. I didn't think D allowed that though.

Ah okay, didn't realize a and b were supposed to be types.  (What I get for reading just 
before bed.)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list