Does associative array change the location of values?
Steven Schveighoffer
schveiguy at gmail.com
Sat Oct 30 11:59:15 UTC 2021
On 10/29/21 8:49 PM, Stanislav Blinov wrote:
> On Friday, 29 October 2021 at 21:00:48 UTC, Steven Schveighoffer wrote:
>
>> This is incorrect, the buckets are each heap allocated. Just the array
>> of bucket pointers would change.
>>
>> In addition, AAs do not deallocate the key/value pairs ever. You are
>> safe to obtain a pointer to a value and it will stay there, even if
>> you remove the key.
>>
>
> Who's going to document these implementation details? ;) I mean, if no
> one, then the above shouldn't be stated. Wouldn't you agree?
It should be documented. There isn't a valid way to remove these
requirements, even if they are currently just an implementation detail
-- code already depends on these properties. And D is a GC-based
language, especially when using AAs. There is no reason to introduce
undefined behavior for existing usage.
> Given the premise of the question at hand, it does seem useful to know
> these. But at least one should stress what is and isn't subject to
> change (even if unlikely).
The whole AA documentation probably needs some attention.
-Steve
More information about the Digitalmars-d-learn
mailing list