Weird interaction of design choices: Duration + sum
Steven Schveighoffer
schveiguy at yahoo.com
Fri Oct 13 19:28:03 UTC 2017
On 10/13/17 3:24 PM, Steven Schveighoffer wrote:
> On 10/13/17 3:11 PM, jmh530 wrote:
>> On Friday, 13 October 2017 at 18:36:58 UTC, Luís Marques wrote:
>>> [snip]
>>
>> What if it were package instead of private?
>
> This wouldn't help, sum is in phobos, Duration in druntime.
>
> The answer is that sum shouldn't be too clever. IMO, initializing to 0
> should be only done if the type's .init value doesn't match 0. Since
> only floating points and char/wchar/dchar do this, just do the Seed(0)
> for those, else use Seed.init.
I take the last part back a bit. Some custom types may default to
NaN-like values, so Seed(0) is necessary.
What should happen is that sum should test if Seed(0) is viable, and if
not, use Seed.init.
-Steve
More information about the Digitalmars-d
mailing list