const AB c = {a,20, numbers};

sclytrack sclytrack at hotmail.com
Mon Apr 16 12:27:12 PDT 2012


On 04/16/2012 08:15 PM, sclytrack wrote:
>
>> const numbers = new int[2];
>> const c = const(AB)(a, 20, numbers);
>> writeln(c);
>> }
>>
>> Bye,
>> bearophile
>
> That's exactly what I needed, thanks.

Seems to be forwarded to the constructor if there is one.


(untested code)

struct B
{
	int [] _list;
		
	this( const int [] list) const
	{
		_list = list;
		//typeof(_list)=int []
		//typeof(list) =const(int[])

	}
}



Because of the const on the back of the constructor.
Normally  the typeof(_list) should be const(int[])
but assignable once, because we are in the constructor.


But a mutable design has been chosen (_list is int [])
until it is baked or cooked
or whatever the terminology. (don't have Andrei's book)
Probably for flexibility. Are there people out there
using this flexibility?

Just pondering,

	Sclytrack


More information about the Digitalmars-d-learn mailing list