Stable name equality

David Feuer david at well-typed.com
Mon Aug 20 22:36:02 UTC 2018


On Monday, August 20, 2018 11:56:44 AM EDT Simon Peyton Jones via ghc-devs wrote:
> I defer to SimonM but IIRC each stable name corresponds to an entry in the stable-name table; the index in the table is the “stable” thing in a stable name.  So I bet that comparison compares these indices.
> 
> If two stable names are pointer-equal, they presumably contain the same index into the table.
> 
> But is the reverse true?  That is, can we be sure that two pointer-distinct stable name objects contain different indices?

I believe so, yes. Each stable name table entry has a pointer to the linked stable name object. Calling makeStableName# checks whether the passed pointer already has a stable name, and, if so, returns the linked stable name object. The design seems a bit surprising to me, but it looks like that's actually how it works, at least for now. Each call locks the stable name table, so it shouldn't be possible to miss entry creation.


More information about the ghc-devs mailing list