[phobos] Proposal of StopWatch module

Andrei Alexandrescu andrei at erdani.com
Fri Aug 20 13:04:54 PDT 2010


I think the code is ready for prime time, modulo the issues below. What 
do you all think?

Overall this is a good example of modern, idiomatic D code. Everything 
is clear, simple, and in the right place. Congratulations, Shoo!

*******

Line 21: please add a comment that you're adding this "import inside 
struct" curiosity with an experimental purpose only.

Line 80: You could an assert or even an enforce here for TICKSPERSPEC.

Line 99: I'm a bit worried that we allow toSeconds for all integer 
widths. Probably if (isIntegral!T && T.sizeof >= 4) would be better.

Line 170: same concern about toMilliseconds - even bigger because there 
are lots more milliseconds out there :o).

Line 197: the parameter name should be msec

Line 218: same discussion about the allowed integral types

Line 245: parameter name

Line 431: "Unused"

Line 469: typedef is deprecated (sorry). That's partly why I'm 
suggesting to go with the enum.

Line 737: I'm afraid you can't put @trusted here because you don't know 
the safety level of BaseFunc and TargetFunc. You'll need to use @system.

Line 739: Since the two aliases are actually functions, you may want to 
start their names with lowercase.

Line 762: Beautiful idiom!


Andrei

On 08/20/2010 02:00 PM, SHOO wrote:
> (2010/08/20 19:35), SHOO wrote:
>> I rewrote:
>> http://ideone.com/5IgYU
>> How about it?
>>
>> P.S. I used an immutable struct for the first time...
>
> Oops, I forgot AUTOSTART.
> http://ideone.com/GiVmf
> AutoStart.yes seems to be slightly redundant.
> How about making a special type AutoStart with typedef and a AUTOSTART
> with constant value(enum)?
> See also: Line415, Line469, Line474-487
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list