Re: Macros for time magic values - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Macros for time magic values
Date
Msg-id 4D7DF45F020000250003B826@gw.wicourts.gov
Whole thread Raw
In response to Re: Macros for time magic values  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Macros for time magic values
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> wrote:
> Tom Lane wrote:
>> some of them are pretty darn questionable because the underlying
>> number *isn't* as well defined as all that.
> 
> The macro does allow us to centralize comments on their
> imprecision,
> e.g.:
> 
> /*
>  *  DAYS_PER_MONTH is very imprecise.  The more accurate value is
>  *  365.2425/12 = 30.436875, or '30 days 10:29:06'.  Right now we
>  *  only return an integral number of days, but someday perhaps we
>  *  should also return a 'time' value to be used as well.
>  *  ISO 8601 suggests 30 days.
>  */
> #define DAYS_PER_MONTH  30      /* assumes exactly 30 days per
>                                  * month */
My first reaction that this change was about a net wash in
readability for me -- in a couple places it might save me a few
moments thinking about what the number was meant to represent,
balanced against following the ctag back to the #define to see what
number was used for things like DAYS_PER_YEAR or DAYS_PER_MONTH.
Comments like the one Bruce cites above seem like they tip the
scales in favor of the patch for me.  Having a place to document
the choice of questionable values seems like it's better than just
using the questionable values "bare" all over the place.  Neither
omission of the justification nor repeating it seems better.
-Kevin


pgsql-hackers by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: GSoC 2011 - Mentors? Projects?
Next
From: Tom Lane
Date:
Subject: Re: Macros for time magic values