www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.bigint.BigInt and const modifier

reply "Ruslan Mullakhmetov" <public mullakh.com> writes:
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))
Feb 16 2014
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
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
Feb 16 2014
parent reply "Ruslan Mullakhmetov" <public mullakh.com> writes:
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 ?
Feb 16 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
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
Feb 16 2014