Open haberdashPI opened 2 years ago
I think automatically supporting anything that can be converted to Nanosecond is a huge footgun. It's not hard to imagine someone creating a timespan with e.g. Ints giving start/stop in seconds or milliseconds without fully understanding what's going on internally and having mysterious, silent breakage (when comparing to other spans with nanosecond-based times).
(of course, the same goes for the TimeSpan(0, 10)
constructor)
Oh good point... mm... for now maybe the #41 should only accept tuples with Period
values.
Yeah, that's a very good point. Scratch that part then.
As noted in #41 by @ararslan:
NamedTuple
s that have:start
and:stop
at minimum, possibly as part of a larger set of keys, e.g.(; start=Second(1), stop=Second(5), event="explosion")
. AFAICT the only real tradeoff is that you get anErrorException
rather than aMethodError
if you're missing:start
or:stop
.:start
and:stop
keys needn't beNanosecond
-valued or evenPeriod
-valued; in the same manner that e.g.TimeSpan(0, 10)
works, we could convert toNanosecond
as needed by definingwhich should provide the same set of guarantees.
NamedTuple
s for free. Hmmm.