[Issue 17526] Add a set method for AA

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 7 11:05:01 PDT 2017


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

--- Comment #4 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
(In reply to hsteoh from comment #3)
> What about a const overload to opIndexAssign that lets you assign to a new
> key, but aborts if the key already exists?

I'm not sure; I think the semantics would be a bit surprising. E.g. generally
if is(typeof(aa[key]=value)) is true, you'd expect it to work at runtime as
well (for POD types, at least).

> I'm a little hesitant about
> adding a whole new method to set a key in an AA.

I think it would be useful, but I agree it's a bigger addition that might use
more discussion. Not enough for a DIP, but it could be discussed in the pull
request if one were to make one.

I know Martin wants to give a templated AA implementation another go soon:
https://wiki.dlang.org/Vision/2017H2_draft

--


More information about the Digitalmars-d-bugs mailing list