On 3/31/16 4:11 PM, Adam D. Ruppe wrote:
On Thursday, 31 March 2016 at 19:57:50 UTC, Walter Bright wrote:
On 3/31/2016 12:44 PM, H. S. Teoh via Digitalmars-d wrote:
Ah, makes sense. But what would aa[x] return?
A bool indicating membership.
Ewww. If it looks like an AA, let's at least keep the AA interface.
aa[x] returns void, which, having no value, would be a compile error.
And how would you add elements to it?
aa[x] = true; // add member x
aa[x] = false; // remove member x
x in aa; // compile error
aa[x] is a compile error since it is of type void.
x in aa returns void*, null if it is not there, not-null if it is there.
Dereferencing a void* is illegal anyway so its value is irrelevant. (I'd
say just use null and cast(void*) 1)
It is actually just a bool, but with consistent typing to other AAs.
Phobos's RedBlackTree works with a literal bool from opIn:
http://dpldocs.info/experimental-docs/std.container.rbtree.RedBlackTree.opBinaryRight.html
But how do you add a key to the set? Currently only allowed via:
a[x] = ...;
-Steve