www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: (git HEAD) std.datetime spewing deprecation messages

On Tue, 03 Jun 2014 18:35:31 +0100
Russel Winder via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Tue, 2014-06-03 at 10:00 -0700, Jonathan M Davis via Digitalmars-d
 wrote:
 On Tue, 3 Jun 2014 07:21:12 -0700
 "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> wrote:

 https://issues.dlang.org/show_bug.cgi?id=12846

 Since when is x.hours, x.minutes, etc., deprecated?

As of Sunday. The problem is that they seem to be very prone for misuse.

I think x.hours and x.minutes are fine per se. I would suggest deeper investigation of the perceived problems rather than just deprecate then remove.
 Not only do they not match what TickDuration uses those same names
 for (it uses them for the equivelent of total!"hours"(), etc.
 rather than get!"hours"(), etc.), which has come up a number of
 times before, but what I've found at work (where we have a C++ port
 of Duration) is that pretty much everyone keeps using get when they
 meant total, consistently causing subtle bugs. So, I've come to the
 conclusion that the current design is just too bug-prone, and by
 deprecating the individual getters and renaming get to getOnly, I
 hope that that will seriously reduce the risk of misuse.

This all sounds like implementation detail rather than API usage. I admit not having used this stuff in D, but the same basic system exists in Groovy and it works just fine.

The problem is that folks assume that they know what the functions do, and they consistently seem to assume incorrectly. I would have thought that having the documentation be clear would have been sufficient, but it hasn't been, because too many people don't read it, or they read it and then don't remember it correctly later. And since getting the individual units of a Duration rather than the total is likely to be a relatively rare operation, I think that having the individual getters for extracting the individual units is just begging for trouble. I fully expect that the vast majority of users who will end up with deprecation warnings due to these changes will have found a bug in their code. - Jonathan M Davis
Jun 03 2014