lvalue - opIndexAssign - Tango

Denis Koroskin 2korden at gmail.com
Fri Mar 13 22:03:11 PDT 2009


On Sat, 14 Mar 2009 06:41:52 +0300, The Anh Tran <trtheanh at gmail.com> wrote:

> Hi,
>
> When porting from c++ to D, i encounter this strange discrimination:
> 1. Built-in AA:
> 	int[int] arr;
> 	arr[123] += 12345;
> 	arr[321]++;
>
> 2. Tango HashMap:
> 	auto hm = new HashMap!(int, int)();
> 	hm[123] += 12345; // error not lvalue
> 	hm[123]++;	// error
>
> D document says current opIndexAssign does not work as lvalue. But why  
> can builtin AA can that? How can i copy builtin AA behaviour?
>
> --------------
>
> Forgive my noob, where is the place to ask question, report bug for  
> Tango?
>
> 1. I can't compile D code using tango hashmap in debug mode:
>
> import tango.util.container.HashMap;
> void main()
> {
> 	auto hm = new HashMap!(uint, uint)();
> }
>
>  > dmd -w -g -debug  hello.d // error
>
> 2. Compile D code using Tango Regex by GDC emit lots of link errors.
>
> 3. Bug in Tango atomicIncrement, atomicDecrement:
>
> int task_done = 0;
> atomicIncrement(task_done);
>
> That function is compiled in asm:
> lock inc byte ptr[task_done];
> Which is wrong. It'll wrap to 0 at 255.
> It should be: lock inc dword ptr[task_done];
>

This one is fixed long ago, try updating your Tango installation.

> 4. There is no atomicAdd(ref original, int newvalue) family. GCC  
> equivalence is __syn_fetch_and_add ...





More information about the Digitalmars-d-learn mailing list