GMP (GNU multiple precision) wrapper for D?

Matthias Walter walter at mail.math.uni-magdeburg.de
Sat Sep 22 04:58:12 PDT 2007


Don Clugston Wrote:

> Michael Kiermaier wrote:
> > Hello,
> > 
> > I like D more and more.
> > 
> > However, one thing I am missing up to now is a D wrapper for GMP (GNU multiple precision library), like the existing C++ wrapper classes.
> > 
> > Searching for "D programming gmp" with google gives some pages which link to this homepage:
> > http://home.comcast.net/~benhinkle/
> > 
> > But I cannot find a D wrapper there.
> 
> I found I have a copy of it. It'll need work to make it compile with recent DMD.
> But it's very old, and D has improved a lot since then. You might be better just 
> running htod or bcd over the gmp headers.
> 
> 

Did anyone take the time and port it? If not, I would start a project at dsource.org and do it. What about Ben Hinkle's port? Is it active, can one get his sources somewhere?

AFAICS, for a port, one would not need to use template metaprogramming like the original authors did in the original gmpxx headers, because classes in D are by reference. Am I right there? At least, for the following examples, there were no unnecessary temporaries:

a = b + c; // constructor of mpz_class was called once, so temporary was assigned directly to the new reference a, without copying data.
a = (b+c) / (d+e); // constructor was called three times, for (b+c), for (d+e) and for the result.

Any ideas or corrections?

best regards
Matthias Walter



More information about the Digitalmars-d mailing list