On 27/09/13 20:20, Walter Bright wrote:
On 9/27/2013 6:47 AM, Joseph Rushton Wakeling wrote:
[...]
Sounds like we have a new champion! Thanks, Joseph!
I've opened up issue tracking on my fork of std.rational:
https://github.com/WebDrake/Rational/issues
This includes the greatest-common-factor bug discovered by MrSmith and others
that I've identified on detailed consideration of the code. Some are more "need
to check out how this works" rather than "it's a problem" style issues.
Quite a few issues arise out of the fact that David Simcha obviously wanted the
rational type to work effectively with any well-defined integer type of any
degree of precision -- from the built-in types to std.bigint.BigInt to any
arbitrary user-defined integer types. (I can imagine that David must have been
anticipating that people might want to use GMP, for example, or to hook into
languages that inherently support arbitrary-precision arithmetic, like Common
Lisp, Haskell or Scheme.)
Most Phobos functions don't have such generic support, so David was forced to
roll his own solutions, including some templates (isIntegerLike, CommonInteger)
to handle these use-cases. In one case (his least-common-multiple function)
there is in any case no Phobos equivalent that I'm aware of.
It seems to me that the best way to handle these issues in the long term is to
ensure that Phobos' existing functions are sufficiently generic to handle what
std.rational needs. However, it'd be nice to get a working std.rational in
place as soon as possible.
So -- what do people advise I do? Take what I can out of std.rational and
submit Phobos patches, or patch it up as it is and submit std.rational for
review, with the review process deciding what stays in and what needs to be
farmed out to other parts of Phobos?