Boost logo

Boost :

Subject: Re: [boost] [gsoc 2013] draft proposal for chrono::date
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2013-05-05 07:28:39


On May 4, 2013, at 5:16 PM, Anurag Kalia <anurag.kalia_at_[hidden]> wrote:

> "natural" factory function -
>
> (the last argument also has an int for succinctness)
>
> year / month / day;
> day / month / year;
> month / day / year;
>
> This notation extends as -
>
> weekday[n] / month / year;
>
> and so on.

Considering Vicente's concept plan, a user-defined date type can be extended readily via make_date(), but not via this notation. I'd consider that another argument against this unless the design provided specific customization points to enable new date types.

> 1) I have dropped no_check option. It is verbose and I never liked that. The
> constructor has a 'raw' feeling to it that lends itself well to an unchecked constructor. We have the other two categories of functions that check the validity.

Why not simply offer, say, date and raw_date? Pick any two names, but one is checked and the other not. Derivation or composition can simplify the implementation if the checked version in terms of the unchecked.

> 2) I include the named factory functions because there seems no other way to make a date with so myriad options. The consistent naming indicates that the same object is being produced; which is exactly what needs to be said.

I like that, of course.

> 3) The "natural" construction (really, we need some name for them) is actually natural. I particularly like the dmy notation in this case, with last argument as int:
>
> day(25) / dec / 2013;

Any one unit can be int, since the others are typed.

> As for the constants, the jan, feb, ..., dec as well as sun, ..., sat are there.

OK

> Moreover, there are also _1st, _2nd, ... , _31st and last.

Why not use (and extend) the placeholders used for bind?

date(_1, dec, 2013);

Those are shorter and less prone to sounding odd. By the latter I mean that I'd never say "first December 2013", but would s/first/one/. OTOH, I would say "December first, 2013", so perhaps we could offer ordinals, too.

Given your preference to provide support only for the YMD order, which is not an order I would speak otherwise, I don't know whether "first" or "one" is more natural, so maybe that also argues for both.

___
Rob

(Sent from my portable computation engine)


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