Re: Macros for time magic values

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Macros for time magic values
Date: 2011-03-14 13:47:10
Message-ID: 4D7E1C5E.8010806@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/14/2011 09:25 AM, Robert Haas wrote:
> On Mon, Mar 14, 2011 at 4:22 AM, Simon Riggs<simon(at)2ndquadrant(dot)com> wrote:
>> On Sat, 2011-03-12 at 22:29 +0200, Peter Eisentraut wrote:
>>> On fre, 2011-03-11 at 12:50 -0500, Bruce Momjian wrote:
>>>> It has bothered me that many of our time routines use special magic
>>>> constants for time values, e.g. 24, 12, 60, etc.
>>>>
>>>> The attached patch changes these magic constants to macros to clarify
>>>> the code. I would like to apply this for 9.1 as a cleanup.
>>> I think it's much clearer with the plain numbers.
>> Yeh. It's not like the values 24, 12 or 60 were going to change.
> I had the same thought.

I think the advantage is that it's much harder to mistype a symbolic
constant and not have it noticed than to mistype a number literal and
not have it noticed. It's debatable whether this advantage is worth the
loss in clarity in the case of very well known values such as seconds
per minute.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-03-14 13:52:51 Re: Avoiding repeated ON COMMIT truncation for temporary tables
Previous Message Magnus Hagander 2011-03-14 13:45:26 Re: Indent authentication overloading