Weird interaction of design choices: Duration + sum

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Oct 13 19:22:19 UTC 2017


On Friday, October 13, 2017 19:11:40 jmh530 via Digitalmars-d wrote:
> On Friday, 13 October 2017 at 18:36:58 UTC, Luís Marques wrote:
> > [snip]
>
> What if it were package instead of private?

What, Duration's constructor? Duration is in core.time, whereas sum is in
std.algorithm. They aren't in the same package on any level.

IMHO, allowing Duration's constructor to be public is just begging for
trouble, which is why it's not public. Time units should be typed, which
they are with dur and its aliases. We've tried to strip all untyped time
units from druntime and Phobos, and AFAIK, we've managed it. Allowing them
is just begging for bugs.

It sounds like that has had an annoying side effect in the case of sum, but
it's not like Duration is going to be the only type out there that doesn't
allow direct construction but can be used with sum. You just have to provide
the seed value yourself.

- Jonathan M Davis




More information about the Digitalmars-d mailing list