On 3/8/2012 4:27 AM, Jonathan M Davis wrote:
On Wednesday, March 07, 2012 08:47:48 Steven Schveighoffer wrote:
On Tue, 06 Mar 2012 12:09:47 -0500, Andrej Mitrovic

<andrej.mitrov...@gmail.com>  wrote:
I'll never forgive std.datetime for this mistake:

auto sw = StopWatch(AutoStart.yes);
writeln(sw.peek.hnsecs);
writeln(sw.peek.nsecs);
writeln(sw.peek.usecs);
writeln(sw.peek.msecs);
writeln(sw.peek.secs); // bzzzzz NOPE
writeln(sw.peek.seconds);

I misspell this thing every single time I use stopwatch to count seconds.

this is a no-brainer:

Duration dur(string units)(long length) @safe pure nothrow
if(units == "weeks" ||
units == "days" ||
units == "hours" ||
units == "minutes" ||
units == "seconds" ||
units == "secs" || // added
units == "msecs" ||
units == "usecs" ||
units == "hnsecs" ||
units == "nsecs")
{
return Duration(convert!(units, "hnsecs")(length));
}

// etc, everywhere "seconds" is used, add "secs" as well.

I'll see if I can do a pull request.

I've avoided that primarily because it results in inconsistent code. It's
pretty much equivalent to adding extraneous aliases, though it's not as bad,
since it's not a general symbol. But if it's a sufficient usability improvement,
then maybe it's a good idea.


In this case, I think it very much is. I saw your explanation earlier that everything sub-second is abbreviated, but to me (and several others, obviously) that's just unintuitive. I see "msecs", "usecs", and so on and I naturally think "secs" rather than "seconds", most likely because it's a part of each abbreviation. Steve's solution is the right one, I think.

Reply via email to