Two easy pieces

Timothee Cour thelastmammoth at gmail.com
Tue Apr 2 09:47:57 PDT 2013


It breaks ufcs chaining so you can't continue the chain, see above.
On Apr 2, 2013 8:45 AM, "Nick Treleaven" <ntrel-public at yahoo.co.uk> wrote:

> On 02/04/2013 14:33, Nick Treleaven wrote:
>
>> On 02/04/2013 01:10, bearophile wrote:
>>
>>> Sometimes you want to print something coming out of a UFCS chain with a
>>> formatting string. In this case you can't append the writef/writefln at
>>> the end of the chain. The problem is easy to solve with two simple
>>> functions like this. Are they worth having in std.stdio?
>>>
>>
>> I think usually the format string is known statically, so we could have
>> a template overload of writef[ln] with a compile-time format parameter.
>>
>> We can then use that overload for UFCS:
>>
>> 5.writefln!"hi %s!";
>>
>
> Of course, the main point of doing that is to compile-time validate the
> format string. But UFCS is a nice consequence.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130402/556008b3/attachment.html>


More information about the Digitalmars-d-learn mailing list