www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Repairing BigInt const

reply Matthias Walter <xammy xammy.homelinux.net> writes:
Hi all,

as it seems, the current version of BigInt is not capable of const, i.e.
BigInt(1) + const(BigInt)(1) does not work.

Is there already an effort to fix this or would it make sense if I had
taken some time to create a fix for it? I have no idea of all the asm in
the x86 specialization but as const is an interface thing, I should be
able to figure out everything without that knowledge. Or are there
general design problems, such that this would be a waste of time?

Matthias
Nov 20 2010
next sibling parent Don <nospam nospam.com> writes:
Matthias Walter wrote:
 Hi all,
 
 as it seems, the current version of BigInt is not capable of const, i.e.
 BigInt(1) + const(BigInt)(1) does not work.
 
 Is there already an effort to fix this or would it make sense if I had
 taken some time to create a fix for it? I have no idea of all the asm in
 the x86 specialization but as const is an interface thing, I should be
 able to figure out everything without that knowledge. Or are there
 general design problems, such that this would be a waste of time?
 
 Matthias

It's been prevented by some compiler bugs. The changes to pure in 2.050 were triggered by attempts to make BigInt pure. 2.051 will include several fixes to nothrow. Note that const is transitive (unlike C++), so it isn't just an interface thing.
Nov 21 2010
prev sibling next sibling parent Matthias Walter <xammy xammy.homelinux.net> writes:
On 11/21/2010 04:33 PM, Don wrote:
 Matthias Walter wrote:
 as it seems, the current version of BigInt is not capable of const, i.e.
 BigInt(1) + const(BigInt)(1) does not work.

 Is there already an effort to fix this or would it make sense if I had
 taken some time to create a fix for it? I have no idea of all the asm in
 the x86 specialization but as const is an interface thing, I should be
 able to figure out everything without that knowledge. Or are there
 general design problems, such that this would be a waste of time?

It's been prevented by some compiler bugs. The changes to pure in 2.050 were triggered by attempts to make BigInt pure. 2.051 will include several fixes to nothrow.

opBinary, etc.) will be pure, right? Or can D structs be pure as well? (Whatever this would mean...)
 Note that const is transitive (unlike C++), so it isn't just an
 interface thing.

That's clear. For "+", I succeeded in making it const, but of course I had to modify the biguintcore module, too. So I guess that you will work on BigInt when 2.051 is out and patch it to work with const and immutable, right? So I have a good chance to have a fixed version in the next month(s)?!
Nov 21 2010
prev sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Matthias Walter <xammy xammy.homelinux.net> wrote:

 On 11/21/2010 04:33 PM, Don wrote:
 Matthias Walter wrote:
 as it seems, the current version of BigInt is not capable of const,  
 i.e.
 BigInt(1) + const(BigInt)(1) does not work.

 Is there already an effort to fix this or would it make sense if I had
 taken some time to create a fix for it? I have no idea of all the asm  
 in
 the x86 specialization but as const is an interface thing, I should be
 able to figure out everything without that knowledge. Or are there
 general design problems, such that this would be a waste of time?

It's been prevented by some compiler bugs. The changes to pure in 2.050 were triggered by attempts to make BigInt pure. 2.051 will include several fixes to nothrow.

opBinary, etc.) will be pure, right? Or can D structs be pure as well? (Whatever this would mean...)

"Making BigInt pure" means making it usable in pure functions. That is, make all member functions pure that can be pure. -- Simen
Nov 21 2010