On Fri, 14 Nov 2003, Jonathan Swartz wrote:

> I guess this boils down to four choices:
>
> 1) give an arbitrary answer
> 2) give a reasonable answer that may depend on the current time (add both
> durations to the current time and compare the resulting times)
> 3) give an answer if it is correct for all times, throw an exception
> otherwise
> 4) always throw an exception
>
> The current behavior is (1). I still favor (2), because it never throws an
> exception. The problem with (3) is that if you write code that compares
> arbitrary durations, it will work most of the time (e.g. during testing) but
> will occasionally throw an exception (e.g. once you're in the wild). It also
> seems more complicated to implement and document, though maybe not by much.

I agree.  Working quietly most of the time and occasionally throwing an
exception that will be hard to explain ("Duration exceeds fuzzy comparison
limits") is not a good behavior.

I don't mind the idea of adding a compare() class method that accepts a
base datetime and uses DateTime->now, per Rick's suggestion.

Overloading comparison to explicitly die also seems reasonable.  It's
annoying the first time it happens, but as I said in my "Industrial
Strength Perl" presentation, it's better to die before you've screwed up
all your data than afterwards.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to