← Back to context

Comment by nlitened

17 hours ago

> “Make invalid states unrepresentable”

I think this phrase sounds good but is not applicable to systems that touch messy reality.

For example, I think it’s not even possible to apply it to the `tm` structure, as leap seconds are not known in advance.

I agree that messy reality can intervene, in the medium term (for about a decade) we'll need to handle leap seconds

But we can do a lot without challenging the messy reality. 61 second minutes are (regrettably) a thing in some time systems, but negative 1 million second minutes are not a thing, there's no need for this to be a signed integer!

  • The struct is also used for date/time arithmetic and the standard library explicitly supports out-of-range values for this reason.

    • I have no doubt that C "explicitly supports" this, but it's a bad idea.

      The C standard library has the excuse that most of it is very old. We should do better.

      1 reply →