SysTime.add!"days" missing

Spacen Jasset spacenjasset at mailrazer.com
Mon Mar 17 09:16:19 PDT 2014


On Monday, 17 March 2014 at 15:24:22 UTC, Ary Borenszweig wrote:
> On 3/17/14, 12:11 PM, Spacen Jasset wrote:
>> On Monday, 17 March 2014 at 14:39:16 UTC, Adam D. Ruppe wrote:
>>> On Monday, 17 March 2014 at 14:31:54 UTC, Spacen Jasset wrote:
>>>> Thanks. What devilish magic allows for the syntax 60.days? 
>>>> (how does
>>>> it work)
>>>
>>> There's a function in core.time:
>>>
>>> Duration days(int n);
>>>
>>>
>>> D functions f(x, t...) can also be called x.f(t) (or x.f 
>>> without
>>> parameters if there's no additional arguments).
>>>
>>> This works on all types, it is called uniform function call 
>>> syntax, or
>>> UFCS. It lets us extend other things with new methods.
>>
>>
>> Thanks Adam, is there a good explanation anywhere? It must be 
>> newish.
>
> http://dlang.org/function.html#pseudo-member

Thanks but I still can't see how it fully explains this: 
writeln("60 days: ", 60.days);

There is some type magic going on somewhere, because 60 is an int 
and days is a random method that happens to belong to Duration.



More information about the Digitalmars-d-learn mailing list