@property - take it behind the woodshed and shoot it? - writefln

Nick Treleaven ntrel-public at yahoo.co.uk
Fri Jan 25 05:45:02 PST 2013


On 24/01/2013 17:04, Philippe Sigaud wrote:
> On Thu, Jan 24, 2013 at 4:53 PM, Nick Treleaven
> <ntrel-public at yahoo.co.uk> wrote:
>
>> write!"%s\n" = someExpression;
>>
>> :-p
>>
>> Seriously, it would be nice to have a compile-time checked format string for
>> writefln.
>
> I made a stab at it in a template tutorial that can be found on github:
>
> https://github.com/PhilippeSigaud/D-templates-tutorial
>
> You can grab the pdf, it's on section 5.11, p. 168 (Statically-Checked Writeln)
>
> Use example:
>
> cwritefln!"For sample #%d, the results are (%s, %f)"( 0, "foo", 3.14);

Yes, I wish that was in Phobos ;-)

In fact, couldn't cwritefln just be a template overload of writefln? The 
string value parameter may be enough to distinguish it from the runtime 
version.


More information about the Digitalmars-d mailing list