[Ns-developers] time management

Gustavo Carneiro gjcarneiro at gmail.com
Wed Aug 25 13:23:37 PDT 2010


On Wed, Aug 25, 2010 at 20:38, Mathieu Lacage <
mathieu.lacage at sophia.inria.fr> wrote:

> On Wed, 2010-08-25 at 19:21 +0200, Mathieu Lacage wrote:
>
> [snip]
>
> > If you want to ask why you can't write instead:
> >
> > Time b = a * 2;
> >
> > it's because this would require one of:
>
> [snip]
>
> hrm, I had one of these aha moments and pushed a patch that allows you
> to write the above and gets rid of the need for the To method. The only
> downside (which I think is an upside actually) is that you are now
> forced to use an explicit Time constructor for the above:
>
> Time a = ...;
> Time b = Time (a * 2);
>
> which mirrors our current use of the Seconds/MicroSeconds/NanoSeconds
> functions.
>

+1

Conversion from Time to int64x64_t never leads to loss of precision, so it
makes sense to be made implicitly.  The reverse isn't true, so an explicit
constructor is better.

And it is reasonably readable, once you learn that Time*int = int64x64_t.
 Perhaps a case could be made for adding an additional operator for the case
of multiplying by integer:

    Time operator* (Time, int);

But I haven't thought out the full implications...


> Mathieu
> --
> Mathieu Lacage <mathieu.lacage at sophia.inria.fr>
> Tel: +33 4 9238 5056
>
>


-- 
Gustavo J. A. M. Carneiro
INESC Porto, UTM, WiN, http://win.inescporto.pt/gjc
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list