Type-specific overloads in Phobos

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sun Nov 3 01:28:18 PST 2013


On 03/11/13 10:18, Dmitry Olshansky wrote:
> //this should work though:
> alias abs = std.math.abs;
> alias abs = std.bigint.abs;

Yea, which makes sense -- any code that needs both should _know_ it needs both.

Actually, abs itself is not really a problem here as std.math.abs should work 
for just about any integer-like type, the real places where this will matter are 
stuff like greatest common divisor or least common multiple ...

I had some concern about generic numerical code that doesn't know the type it's 
operating on, but on the other hand such code probably shouldn't be calling a 
specific implementation of (e.g.) abs, gdc or whatever.


More information about the Digitalmars-d-learn mailing list