Re:Please reconsider the Boolean evaluation of midnight
by moomin on Friday March 07, 2014 @05:22AM
(#7359467)
I think what he was saying was:
* You should use + only for operations that form an abelian group across the domain
* In those cases, it makes sense for the identity to be false.
The truth is, time doesn't have a sensible addition/combination operator, never mind an identity and inverse, so it isn't even a group.
Re:Please reconsider the Boolean evaluation of midnight
by baddox on Friday March 07, 2014 @04:49PM
(#7362959)
Okay, I definitely buy that. It makes sense to add a duration (timedelta in Python) to a time, but not to add times to one another.
This is venturing off topic, but if you really wanted to, you could define addition for times in terms of timedeltas. It makes sense to subtract times and get a timedelta, so you could define addition as the subtraction with signed times and signed timedeltas. So, since `time(today) - time(yesterday) = timedelta(1 day)`, we could say that `time(today) + time(yesterday) = -timedelta(1 day)` and `time(today) - -time(yesterday) = timedelta(1 day)`. It's a bit strange to define the notion of a signed time object, but it could work.
Re:Please reconsider the Boolean evaluation of midnight
by k2enemy on Friday March 07, 2014 @05:26AM
(#7359477)
Yeah, I was trying to figure that out too. They seem to care about closure and identity, but most of the examples have operators that trivially break an Abelian group's commutative requirement.
The code examples seem to be referring to the existence of an identity element, which is necessary for all groups.