(git HEAD) std.datetime spewing deprecation messages

Byron Heads via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 6 05:58:14 PDT 2014


On Thu, 05 Jun 2014 21:00:39 +0200, Jonathan M Davis via Digitalmars-d
wrote:

> It's a common idiom in core.time and std.datetime to use strings to
> represent units when you need to give the units as template arguments.
> If it hade't been strings, it would have been an enum (otherwise, they
> would risk conflicting with local variables and whatnot), in which case
> it would have been even more verbose - e.g. Units.days, Unit.seconds,
> Unit.msecs (and IIRC, I originally had something like that until Anrei
> suggested that I use strings in the original review for std.datetime).
> Also, days, seconds, and msecs are free functions in core.time which
> forward to dur!"days", dur!"seconds", and dur!"msecs", so trying to use
> them on their own would try and use those free functions, which
> obviously isn't what we want at all. I can see why you might want to
> remove the quotes, but they really aren't that bad, and using strings
> for this purpose has turned out to be extremely useful and flexible.
> 
> - Jonathn M Davis

Yeah its more of a pipe dream, kinda of how we have moved away from 
passing strings and use the short hand versions of lambdas.  A CTFE 
helper might make it look better, saw this somewhere on the form. 

d.splitHelper!q{days, second, msecs}(...)

the function name is not import here just the idea.  There is a stdx 
project on code.dlang, might be a good place for little helpers like this.


More information about the Digitalmars-d mailing list