lvalue - opIndexAssign - Tango
Daniel Keep
daniel.keep.lists at gmail.com
Fri Mar 13 21:40:04 PDT 2009
The Anh Tran 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?
You can't. This is a hole in the language at the moment, hopefully
solved by the introduction of ref returns (but that's in D 2.0 which you
don't want to use at the moment.)
> Forgive my noob, where is the place to ask question, report bug for Tango?
You could try the Tango IRC channel:
irc://irc.freenode.org/#d.tango
That, or the Tango forums:
http://dsource.org/projects/tango/forums
You can report problems with Tango via the ticket system:
http://dsource.org/projects/tango/report ("New Ticket" is down the
bottom of the page.)
> 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
When posting problems with compiling something, it helps to mention the
version of the compiler you're using, your platform, the version of
Tango (in this case) and what the error actually is.
> 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];
>
> 4. There is no atomicAdd(ref original, int newvalue) family. GCC
> equivalence is __syn_fetch_and_add ...
-- Daniel
More information about the Digitalmars-d-learn
mailing list