std.rational?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Sep 30 09:54:55 PDT 2013


On 30/09/13 15:34, MrSmith wrote:
> Here is my thoughts:
> 1) instead of gcf use updated std.numeric.gcd. Replace lcm, iAbs, floor, ceil,
> round functions with appropriate analogues from phobos.

There is no equivalent to lcm in Phobos that I'm aware of.  floor, ceil and 
round -- these are type-specialized versions of generic functions and I'm not 
sure in this case whether the norm is for them to accompany the type definition 
or not.

std.numeric.gcd is currently inadequate for use with BigInt -- it could and 
should be patched but as a short-term workaround it may be preferable to have a 
private std.rational.gcf that works.

> 2) instead of isIntegerLike use similar template from std.traits (like isIntegral).

isIntegral is inadequate for purpose here because it only checks if a type is 
one of the built-in integer types -- it doesn't count BigInt as integral 
(although perhaps it should) and won't work with other arbitrary integer-like 
types if that's desired.

> 3) replace isAssignable by std.traits.isAssignable or better use
> std.traits.isImplicitlyConvertible. Now i am unable to assign integer directly
> to rational, instead i am forced to use rational(integer) method;

OK, I'll look into that.

> 4) replace CommonInteger by std.traits.CommonType

Not sure that's adequate -- will it handle the case of BigInt?



More information about the Digitalmars-d mailing list