Type safety and time units in Go and D

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 20 06:28:34 PST 2015


On Tuesday, January 20, 2015 08:24:34 Steven Schveighoffer via Digitalmars-d wrote:
> On 1/20/15 5:44 AM, Atila Neves wrote:
> > My buddy Jeff never learns... he sent me a blog post link about Go
> > development today and I ended up comparing how the bug mentioned in the
> > blog post wouldn't happen in D:
> >
> > https://atilanevesoncode.wordpress.com/2015/01/20/type-safety-and-time-intervals-in-d-and-go/
>
> On the question of why that is the way it is, it's because we actually
> thought of all that shit when designing the time library :) I was a big
> proponent of not using the same type to mean duration and timestamp, and
> only allowing sane operations. Jonathan was the same way.

That separation is one of the main reasons for introducing MonoTime
recently as a replacement for TickDuration, because TickDuration conflates
the monotonic timestamp and monotonic duration. With MonoTime, we end up
with a separate monotonic timestamp and then use the same duration type that
we've been using everywhere else (Duration), which then also has the benefit
of reducing the number of duration types (which has caused far too much
confusion). But TickDuration was a minimally changed version of SHOO's Ticks
type, and I did a very poor job of integrating it into core.time and
std.datetime when std.datetime was introduced. It's never really fit with
the rest.

- Jonathan M Davis



More information about the Digitalmars-d mailing list