I made std.time for Phobos, please review my code.

SHOO zan77137 at nifty.com
Wed Apr 28 06:47:02 PDT 2010


Steven Schveighoffer さんは書きました:
> On Tue, 27 Apr 2010 12:32:44 -0400, SHOO <zan77137 at nifty.com> wrote:

> The internal storage is via integer, so if for example the integer 
> number of milliseconds is desired, doing the calculation via converting 
> to a floating point, and then scaling/truncating is inefficient, subject 
> to floating point error, and more convoluted than it has to be.  I'd 
> rather have an exact method that is as fast as possible, and is as 
> simple as possible.  It is not too much extra to add these methods (they 
> are pretty much boilerplate code).
> Many existing C libraries and network protocols encode time via 
> integers, so there is real need to be able to convert to these units, 
> and to allow it with as little syntax as possible is good.

Even if there are Span.seconds, Span.mseconds...etc., it is not strange. 
In addition, it give the symmetry with seconds, mseconds ...etc.
I'm getting the feeling that the one that there are not the methods is 
strange than there are.
I'll try it.


> Then all that is left is the name, Clocks is not a good name for a value 
> type entity.  It seems more suited for a static entity that contains 
> clocks.  You already have defined interval, so that is out.  I can't 
> think of anything good right now, but it definitely should not be a 
> plural word.
> 
> This is a very solid library, very little to complain about!

I have sense of incongruity for a name of Clocks. But good ideas about 
the name did not appear. Do you have any ideas? >ALL

> One thing I would suggest if this is assimilated into druntime/phobos is 
> that we split the Span functionality out into it's own module (or put it 
> in object.di) so it can be used in druntime for things like Thread.sleep.

It's nice.
Thread.sleep confuses me a little because the argument's number of 
digits is too big.
I hope so strongly.

> -Steve


More information about the Digitalmars-d-announce mailing list