Proof of concept - library AA

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed May 27 11:31:19 PDT 2015


On Wed, May 27, 2015 at 05:16:51PM +0000, IgorStepanov via Digitalmars-d wrote:
> On Wednesday, 27 May 2015 at 14:12:02 UTC, Martin Nowak wrote:
> >On Sunday, 24 May 2015 at 15:13:41 UTC, Vladimir Panteleev wrote:
> >>Could you elaborate on what these magic semantics are?
> >>
> >>>and no easy solution exists for the ++aa[key1][key2] case.
> >>
> >>Is this specific to the pre-increment? aa[key1][key2]++ is generally
> >>a useful pattern.
> >
> >This applies to pre/post increment as well as assignment and
> >opOpAssign.  When an lvalue is needed the compiler will call a
> >special runtime function GetX to obtain an lvalue for aa[key1], i.e.
> >the entry will be default initialized iff missing.
> >If the expression is an rvalue though (aa[key1][key2]), a missing
> >key1 will trigger a range error.
> >In an opIndex(Key) you have no idea whether the whole expression I an
> >lvalue or an rvalue.
> >
> >IIRC the construction/assignment of a value is also handled
> >specifically.
> 
> BTW, may be we should create DIP about opIndex extending?
[...]

See: https://issues.dlang.org/show_bug.cgi?id=7753

This issue has been known since 2012.


T

-- 
Genius may have its limitations, but stupidity is not thus handicapped. -- Elbert Hubbard


More information about the Digitalmars-d mailing list