Anything in the review queue?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 23 11:09:32 PDT 2011


On 3/21/11 10:25 PM, Don wrote:
> Andrei Alexandrescu wrote:
>> I think by and large failure to define rational for BigInt in a way
>> that has many commonalities with rational for built-in integrals
>> reflects a failure of BigInt. By its very design, BigInt is supposed
>> to transparently replace integers.If this is largely the case, the design
>> has succeeded. If the design of anything must be reworked essentially
>> from scratch to work with BigInt instead of int et al, then the
>> abstraction may be too porous to be useful.
>>
>> There are a few approaches we can take from here. One is to define
>> certain traits that differentiate BigInt from other integrals (e.g.
>> preferAdditionToMultiplication or whatnot), and then design Rational to
>> use those traits. Another is of course to specialize the entire
>> Rational on BigInt. Third would be to specialize certain core routines
>> (gcd and friends) for BigInt and keep Rational agnostic.
>
> You're missing something important here. Rational big integers are a
> very well defined area of research, with its own set of algorithms.
> Although you can pretend a BigInt behaves as an int, and make a rational
> type, the performance will be pathetic, and everyone will laugh at you.

Interesting. Thanks for the insight (missed this post) for a while.

Andrei


More information about the Digitalmars-d mailing list