Discussion Thread: DIP 1042--ProtoObject--Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Sat Jan 15 10:15:16 UTC 2022

On 15.01.22 10:34, Elronnd wrote:
> On Saturday, 15 January 2022 at 08:33:45 UTC, Timon Gehr wrote:
>> `pure` toHash can also be rather problematic in case it returns the 
>> address of the object as an integer (as it currently does by default). 
>> Pure code should not depend on GC memory addresses.
> There has been a comment about that in object.d for over a decade; in 
> that time, no one has made a compacting GC.  More practically, if 
> somebody does write a compacting GC, it will be child's play for them to 
> go and add a 'hash' field to Object and change the implementations of 
> cmp and toHash.
> (Obviously userspace code should not depend on such mechanisms, but for 
> druntime, what is the problem?)

The issue is not that addresses might change, it's that they depend on 
global state. Therefore, e.g., iteration order for an associative array 
will depend on global state too. It's just not `pure`.

More information about the Digitalmars-d mailing list