News for hackers. Stuff that matters.
Re:When a+b+c does not equal c+b+a by DannoHung on Friday June 05, 2015 @09:40AM (#9665407)
Is it really overloading that's the problem here? Even if you used method names to do this, you'd still have to deal with the fact that the operation being performed is non-commutative.

I don't know that there is a way of expressing such a restriction even if you were using dependent types in such a way as to prevent shooting yourself in the foot here. Possibly you could not implement the month or year span elements altogether and only allow addition of days or seconds?

Re:When a+b+c does not equal c+b+a by erdeszt on Friday June 05, 2015 @12:57PM (#9666554)
But nested method calls don't imply commutativity while addition does. So the code is misleading.
Re:When a+b+c does not equal c+b+a by DannoHung on Friday June 05, 2015 @02:14PM (#9667035)
I don't follow. How do nested method calls fail to imply commutativity?

For example, using psuedo-Haskell notation:

    (+):: Int -> Int -> Int

    ; ncc short for non commutative combination
    ncc:: Time -> Time -> Time

    1 + 2 + 3

    ncc 03:00 (ncc 10:00 02:00)
Re:When a+b+c does not equal c+b+a by erdeszt on Friday June 05, 2015 @04:24PM (#9667887)
It could be just me but I would expect something that looks like an addition to be commutative but not arbitrary function calls. But I see what you mean that the types are not much of a help here.