July 12, 2007Re: This is SO crazy. D has variable template args!
Posted in reply to Craig Black
Reply to Craig, > I agree with most that the use of << and >> or other forms of operator > overloading are inappropriate to process variable number of arguments. > D has variable template args built in to the freakin language. It's > typesafe, elegant, and straightforward. > > // C++ yuck > cout << "x is " << x << endl; > // Tango yuck > Stdout("x is ")(x).newline; > // Would be best and very easy to implement > write("x is ", x, newline); > -Craig > how about: alias Teritef!("this is the format %B %xL %eR\n") myWrite; // args == (bool, long, real) output = (T/F, hex, exponent) My only issue is that it needs to be some sort of wrapper or huge code bloat will be a problem.