std.bigint.BigInt and const modifier

2014-02-16 Thread Ruslan Mullakhmetov



BigInt is a struct == ValueType, suppose i can assign 
const(BigInt) to BigInt

const(BigInt)/const(BigInt) do not compile.

Is it a bug or design considerations?

test.d

import std.stdio;
import std.bigint;

void foo(BigInt b)
{
std.stdio.writefln(foo(%s), b);
}

void main()
{
const BigInt b = BigInt(445216415446);

auto b1 = b / b;

foo(b);
}


$ dmd test.d
/tmp/test.d(14): Error: 'b' is not of arithmetic type, it is a 
const(BigInt)
/tmp/test.d(14): Error: 'b' is not of arithmetic type, it is a 
const(BigInt)
/tmp/test.d(16): Error: function test.foo (BigInt b) is not 
callable using argument types (const(BigInt))


Re: std.bigint.BigInt and const modifier

2014-02-16 Thread bearophile

Ruslan Mullakhmetov:


Is it a bug or design considerations?


It was a const correctness bug, but it's already fixed in recent 
D compilers.


Bye,
bearophile


Re: std.bigint.BigInt and const modifier

2014-02-16 Thread Ruslan Mullakhmetov

On Sunday, 16 February 2014 at 20:36:32 UTC, bearophile wrote:

Ruslan Mullakhmetov:


Is it a bug or design considerations?


It was a const correctness bug, but it's already fixed in 
recent D compilers.


Bye,
bearophile



recent D compilers.


i use v2.064.2. is it outdated ?


Re: std.bigint.BigInt and const modifier

2014-02-16 Thread bearophile

Ruslan Mullakhmetov:


i use v2.064.2. is it outdated ?


It will be fixed in dmd 2.065. It's not yet out but you can use 
it already if you want to be on the bleeding edge, it's 
currently in beta3 and most regressions are fixed, so it's 
probably better than using dmd 2.064.2.


Bye,
bearophile