[m-rev.] multi-precision integers based on GMP

Julien Fischer jfischer at opturion.com
Tue May 26 09:06:56 AEST 2015


Hi Matthias,

On Mon, 25 May 2015, Matthias Güdemann wrote:

> I created a binding to GMP which offers a gmp_int data-type
> corresponding to mpz_t, the GMP multi-precision signed integer.

Nice work!

> It exports standard arithmetic operations, bitwise operations and some
> number theoretic functions.
>
> While libgmp is more complex than libtommath, its performance is much
> better. Using gmp_int puts big integer arithmetic in Mercury close to
> the performance of Haskell and OCaml and outperforms other logic
> programming systems as SWI or YAP. There is deliberately not much error
> checking going on, I really think that performance should be the number
> one goal here.
>
> I created a pull-request for this:
>
> https://github.com/Mercury-Language/mercury/pull/25

I've had a quick glance through the pull request; one thing you should
do is set the 'can_pass_as_mercury_type' attribute on the foreign type
pragma for the type gmp_int/0.  In the absence of that attribute the
compiler may box values of that type.

Cheers,
Julien.


More information about the reviews mailing list