(git HEAD) std.datetime spewing deprecation messages

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 5 07:18:59 PDT 2014


On Thu, Jun 05, 2014 at 01:23:47AM -0700, Jonathan M Davis via Digitalmars-d wrote:
> On Wed, 04 Jun 2014 09:12:06 +0200
> Sönke Ludwig via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> 
> > Just a minor note: What about just .only!"minutes", analogous
> > .total!"minutes"? Removing both the .minutes shortcut and the short
> > "get" method, pretty heavily increases verbosity, so shortening
> > "getOnly" might be a good idea.
> 
> Actually, after some further discussion, I think that we've decided to
> remove get/getOnly entirely. Instead, we'll have a function called
> split which splits the Duration among the units that you request
> (rather than just one).  I'll be updating the current pull request
> with those changes shortly, so we may not end up with exactly what I
> have at the moment, but these are the currently proposed documentation
> examples for split:
> 
> {
>     auto d = dur!"days"(12) + dur!"minutes"(7) + dur!"usecs"(501223);
>     long days;
>     int seconds;
>     short msecs;
>     d.split!("days", "seconds", "msecs")(&days, &seconds, &msecs);
>     assert(days == 12);
>     assert(seconds == 7 * 60);
>     assert(msecs == 501);
[...]

Very nice! I like this. It looks very D-ish, and very idiomatic.

It also solves an API problem that I've encountered before, where a
database wrapper module needs to allow client code to query some data
from a database, but the client code needs the flexibility to select
(ha!) which fields to include in the result because of performance:
there are many columns and the number of rows returned may be a large
number. Using compile-time field lists like you did here is an excellent
way to solve this problem, since you don't have to introduce extra
indirection, but you can bind the database columns to output fields at
compile-time for maximum performance.


T

-- 
Старый друг лучше новых двух.


More information about the Digitalmars-d mailing list