[Issue 4965] Lacking int, uint etc. versions of most std.math functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 1 05:44:47 PDT 2010


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



--- Comment #3 from Don <clugdbug at yahoo.com.au> 2010-10-01 05:44:29 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > Essentially, they are hack for the fact that integer literals don't implicitly
> > convert to double.
> 
> Aside from labelling it as a "hack" (which is personal opinion), what is your
> problem with it i.e. does it actually cause any problems, or have any negative
> side effects?

> Normally, a hack is something that is done for short-term convenience but
> introduces long-term problems (or problems that only occur in rare situations).
> I fail to see any problems introduced by allowing integer arguments to these
> functions

Have you seen the code in std.math? It is a really foul hack.

If you have a function with 3 arguments, you need to write more than 1000
function overloads. I'm not kidding. Worst code bloat I've seen in my life.

The reason why this problem with sqrt arose, is that originally, we only had
real sqrt(real), and everything was fine. Then, for reasons I don't understand, 
overloads for float sqrt(float) and double sqrt(double) were added.
Once those were added, integer arguments failed to work.

The correct solution at this stage of the language would have been to remove
those essentially useless overloads until the language can support them
properly. The only place they make any difference is when there is type
inference involved.

-- 
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