[Issue 6725] core.time.dur should accept floating point

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 8 23:04:23 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=6725



--- Comment #6 from Walter Bright <bugzilla at digitalmars.com> 2013-02-08 23:04:15 PST ---
1. Using floating point for time is like using floating point for accounting
software ($57.23). It doesn't work for things that come in discrete quanta
(pennies, clock ticks). You will spend FAR more time chasing weird problems
than you will save in "convenience". Yes, I have experience with this, and I
understand floating point (having build FP emulators).

2. Many machines have very poor FP performance compared with integer
performance. Implementing basic operations using unnecessary FP results in
slow, bloated code.

3. Phobos' time functions are already massively complex. I still can't even
compile the datetime unittests on a 512Mb machine. Please, no more.

4. It's trivial for a user to write their own FP wrapper around dur. There is
no reason to integrate this into dur itself. Software should be pieced together
using layers of abstraction, not kitchen sink base types.

5. It would take longer to read the documentation for this enhancement than to
just convert your floating point value to an int.

6. You're not forced to write long complicated expressions to convert fp to
integers. It's just a scale and a cast:

    dur!("secs")(1.5001) => dur!("nsecs")(cast(long)(1.5001 * 1000000));

I.e. I feel pretty strongly this is a bad idea for Phobos.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list