January 11, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Wednesday, 11 January 2017 at 22:14:03 UTC, Nordlöw wrote:
> One important thing...you've forgotten to qualify the D wrapper functions as `pure @nogc`.
in the actual bindings, I did include pure & nothrow however I've not had time in the wrapper.
|
January 11, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Hall | On Wednesday, 11 January 2017 at 22:18:53 UTC, Andrew Hall wrote:
> On Wednesday, 11 January 2017 at 22:14:03 UTC, Nordlöw wrote:
>> One important thing...you've forgotten to qualify the D wrapper functions as `pure @nogc`.
>
> in the actual bindings, I did include pure & nothrow however I've not had time in the wrapper.
also, why nogc?
|
January 11, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Hall | On Wednesday, 11 January 2017 at 22:19:58 UTC, Andrew Hall wrote:
> also, why nogc?
Because C-functions never use the D garbage collector :)
|
January 12, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Wednesday, 11 January 2017 at 23:12:30 UTC, Nordlöw wrote:
> On Wednesday, 11 January 2017 at 22:19:58 UTC, Andrew Hall wrote:
>> also, why nogc?
>
> Because C-functions never use the D garbage collector :)
They should also be marked nothrow. That and @nogc should generally be applied to all C function bindings, but pure only on those which actually are pure.
|
January 12, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Thursday, 12 January 2017 at 02:12:01 UTC, Mike Parker wrote:
>
> They should also be marked nothrow.
Which I see they are.
|
January 12, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Thursday, 12 January 2017 at 02:12:01 UTC, Mike Parker wrote:
> On Wednesday, 11 January 2017 at 23:12:30 UTC, Nordlöw wrote:
>> On Wednesday, 11 January 2017 at 22:19:58 UTC, Andrew Hall wrote:
>>> also, why nogc?
>>
>> Because C-functions never use the D garbage collector :)
>
> They should also be marked nothrow. That and @nogc should generally be applied to all C function bindings, but pure only on those which actually are pure.
Just added @nogc. Cheers
|
January 12, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw Attachments:
| On Wed, 2017-01-11 at 18:32 +0000, Nordlöw via Digitalmars-d wrote: […] > Great. I'll merge mine and your's stuff and put it in > > https://github.com/nordlow/gmp-d.git > […] Is the intention for this to stand with or replace std.bigint ? -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
January 12, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Thursday, 12 January 2017 at 09:19:26 UTC, Russel Winder wrote:
> Is the intention for this to stand with or replace std.bigint ?
I have no plan yet. I'm just gonna work on it for fun until it covers most of GNU MP. Pull requests are very welcome.
|
January 15, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Thursday, 12 January 2017 at 16:55:10 UTC, Nordlöw wrote:
> On Thursday, 12 January 2017 at 09:19:26 UTC, Russel Winder wrote:
>> Is the intention for this to stand with or replace std.bigint ?
>
> I have no plan yet. I'm just gonna work on it for fun until it covers most of GNU MP. Pull requests are very welcome.
What would be cool would be a way for D to generate 'optimal' gmp code. So a template function that takes in an expression, and output's D / GMP code that uses minimal allocation.
ulong a = 27, b = 84, c = 110, d = 133;
compileGMP!"Integer res = a ^^ 5 + b ^^ 5 + c ^^ 5 + d ^^ 5"();
might generate the code:
Integer res, r2; //r2 used as a register of sorts (minimise allocation of Integers)
mpz_init(res); mpz_init(r2);
mpz_ui_pow_ui(res, a, 5);
mpz_ui_pow_ui(r2, b, 5);
mpz_add(res, res, r2);
mpz_ui_pow_ui(res, c 5);
mpz_add(res, res, r2);
mpz_ui_pow_ui(r2, d, 5);
mpz_add(res, res, r2);
Obviously the compileGMP function would need to know a bit about the types, but that can be arranged. Just something to think about ;)
|
January 16, 2017 Re: libgmp deimos library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Hall | On Sunday, 15 January 2017 at 03:04:30 UTC, Andrew Hall wrote: > On Thursday, 12 January 2017 at 16:55:10 UTC, Nordlöw wrote: >> On Thursday, 12 January 2017 at 09:19:26 UTC, Russel Winder wrote: >>> Is the intention for this to stand with or replace std.bigint ? >> >> I have no plan yet. I'm just gonna work on it for fun until it covers most of GNU MP. Pull requests are very welcome. > > What would be cool would be a way for D to generate 'optimal' gmp code. So a template function that takes in an expression, and output's D / GMP code that uses minimal allocation. I'm gonna solve this with expression templates instead: https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L1725 in use for instance here https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L1744 I'm gonna activate it in the operator overloads for MpZ this week. |
Copyright © 1999-2021 by the D Language Foundation