Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-04-14 15:47:22


"Powell, Gary" <powellg_at_[hidden]> writes:

>>> I think readability is more important. Nobody but pedants have
>>> problems with string + string. Likewise I think:
>>>
>>> d + 2*months
>>>
>>> or whatever is better than the functional-looking alternatives.
>
>>If there was universal acceptance of what it means to add two
>>months to a date, I might agree. Given the imprecise notion of
>>what it means to add two months, however, I disagree.
>>"next_month" or "increment_month" versus "add_month" better
>>distinguish the imprecision.
>
> Here I totally agree with Rob, adding months is a non-intuitive operation and
> calling out the precision helps the readability of the program.
>
> It makes perfect sense to do
>
> d + (30 * days)
>
> but not with Months.

It makes perfect sense if you know the semantics the library assigns
to months.

Does the library have a concept of a month with no day, e.g. January
of 2004? If so, I'd be happy to say

   date(d.month() + 2*months, d.day)

That, too, calls out the fact that adding months to dates has a
dubious meaning.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk