Associative Arrays in the data segment

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 07:40:35 PDT 2015


On 4/10/15 10:20 AM, Daniel Murphy wrote:
> "Steven Schveighoffer"  wrote in message
> news:mg8ln4$1dtb$1 at digitalmars.com...
>
>> It's all the rage these days, Walter just started a thread on it ;)
>
> Thread != activity.

Well, it was a call to action by the language designer "here's a fun 
project anyone can do". Would be a shame for an unsuspecting person to 
do that, and then find out "oh, we can't use your work, because the 
compiler has an implementation already, and (insert some wrinkle why 
it's too difficult to update the compiler version to do what yours does)"

>> But the issue I see is that this is a step BACKWARDS. We want to move
>> to more possibility of customization, not less. Subtle differences in
>> compiler/library implementation are the stuff nightmare bugs are made of.
>
> It lets us do something we currently can't do but want to, at the cost
> of making something we could do but haven't for years slightly harder.

Yes, I understand this. But I'm very firmly against putting more magic 
into the compiler. How many bugs or barriers to improvement are root 
caused by compiler magic treatment of something?

> If somebody really wants to improve the runtime AA implementation, they can
> a) Update the compiler code to do the same thing
> b) Ask me and I'll do it
>
> Not being able to put AAs in the data segment is a stupid limitation
> that we should have fixed years ago.

There are many stupid limitations that should have been fixed years ago. 
And I don't disagree this is one of them. I just disagree that this is a 
"fix". It's quite literally the introduction of a new problem that we 
don't need.

>> I think it's possible now, but nobody has been able to exactly
>> duplicate certain aspects of the builtin AA. I may take a stab at it.
>> We also had a horrible experience of "half-library half magic" type a
>> few years ago.
>
> The only positive thing that's made it into master in the last few years
> is rolling back the AA implementation.

No, the most significant change is making it so opEquals is used instead 
of opCmp for key lookup. And that was like pulling teeth.

>> But the real answer is, as soon as someone does it who has
>> Walter's/Kenji's/your ear, we can create an AA, and fix the compiler
>> to use and support it. It needs an advocate (who is willing to do the
>> hard work).
>
> I'm not holding my breath.

Clearly :)

-Steve


More information about the Digitalmars-d mailing list