You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for Time.fromSeconds, Time.fromMilliseconds, Time.fromMicroseconds, and Time.fromNanoseconds is (emphasis mine):
These convert the number n to a time value denoting n seconds (respectively, milliseconds, microseconds, or nanoseconds). If the result is not representable by the time type, then the exception Time is raised.
The wording here makes it seem like an implementation should raise the Time exception when the time is too precise for the implementation, but this does not seem to be implemented in practice.
val t = Time.fromNanoseconds 1
val nsec = Time.toNanoseconds t
val () = TextIO.print ("Nanoseconds: " ^ LargeInt.toString nsec ^ "\n")
(* MLton *)
Nanoseconds: 1
(* SML/NJ *)
Nanoseconds: 0
(* Poly/ML *)
Nanoseconds: 0
Proposal:
Make clear what the expected behaviors of the Time conversion functions are.
This could be done by adding the sentence from the Time.fromReal function:
Depending on the resolution of time, fractions of a microsecond may be lost.
The text was updated successfully, but these errors were encountered:
I do not remember the rationale for that language, but I suspect that the intention was focused on overflowing the internal representation (rather than underflow).
It might also be useful to add a constant
val tick : time
to the interface that is minimum representable unit of time.
The documentation for
Time.fromSeconds
,Time.fromMilliseconds
,Time.fromMicroseconds
, andTime.fromNanoseconds
is (emphasis mine):The wording here makes it seem like an implementation should raise the
Time
exception when the time is too precise for the implementation, but this does not seem to be implemented in practice.Proposal:
Make clear what the expected behaviors of the
Time
conversion functions are.This could be done by adding the sentence from the
Time.fromReal
function:The text was updated successfully, but these errors were encountered: