Type safety and time units in Go and D

via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 20 03:31:52 PST 2015


On Tuesday, 20 January 2015 at 10:44:54 UTC, 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/

FWIW this is type safe in a duck-typing language like Python too:

from datetime import timedelta

t = timedelta(10)
assert( t + t == timedelta(20) )
t*t

TypeError: unsupported operand type(s) for *: 
'datetime.timedelta' and 'datetime.timedelta'


More information about the Digitalmars-d mailing list