|
From: Jens T. <Je...@Th...> - 2003-07-23 10:39:39
|
Hi there,
one idea here: implement < and > for the cases were it is well defined, =
and
expand =3D=3D to be "not larger and not smaller", eg.
4w<1m false
4w>1m false
4w=3D=3D1m expands to ( !(4w<1m) && !(4w>1m) ) which is true
28d<1m false
31d>1m false
=20
30d=3D=3D1m expands to ( !(30d<1m) && !(30d>1m) ) which is true
This could also be done in a Compare() function that returns either -1, =
0 or
1 to make sure that absolutely noone uses the operators carelessly.=20
Regards,
Jens.
c) Maybe Period::operator=3D=3D should be a partial function. There's a =
subset=20
of the domain where it is well defined ("1 year =3D=3D 12 months" is ok, =
and so=20
is "3 days =3D=3D 3 days" and "14 days =3D=3D 2 weeks") but how about =
"31 days =3D=3D 1=20
month"? Or "4 weeks =3D=3D 1 month"? With the current implementation, =
the first=20
is false, with the disconcerting result that if d =3D Date(22,7,2003), =
p1 !=3D=20
p2 but d.plus(p1) =3D=3D d.plus(p2). The second is true, but for most =
dates,=20
d.plus(p1) !=3D d.plus(p2). How about throwing an exception if the =
=3D=3D is=20
undecidable?
|