[phobos] datetime review
Andrei Alexandrescu
andrei at erdani.com
Sat Oct 9 15:16:56 PDT 2010
On 10/9/10 15:54 CDT, Simen Kjaeraas wrote:
> Andrei Alexandrescu <andrei at erdani.com> wrote:
>> * "this(string msg, string file = __FILE__, size_t line = __LINE__,
>> Throwable next = null) nothrow" -> the __FILE__ and __LINE__ are
>> useless (they are yours, not your caller's). You need to make them
>> template parameters to work, see other places in Phobos. At least
>> that's what I recall. Walter?
>
> You're wrong, they are replaced at call point.
Thanks for the correction. For enforce() I advocated the hack to Walter
in template arguments, and he introduced it. Now I see he introduced it
in two places. FWIW I think this is a welcome irregularity in default
args as well; you almost never care about the callee's __FILE__ and
__LINE__ in a default argument.
>> long convert(TUnit from, TUnit to)(long);
>
> Couldn't this be more succinct by copying std.conv.to's system?
>
> i.e:
> assert( convert!years( months( 24 ) ) == 2 );
This would be the case if we go with separate types for duration units
(years, months,...), but not if we use long throughout.
My thought for simplification: go with one 128-bit Duration (which is
now JointDuration) and then have it offer @properties such as e.g.
years() returning double.
Andrei
More information about the phobos
mailing list