Thread overview
[Issue 2482] Spec does not reference about special x functions in TypeInfo_Struct
Dec 21, 2019
berni44
Dec 17, 2022
Iain Buclaw
December 22, 2016
https://issues.dlang.org/show_bug.cgi?id=2482

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |trivial
                 CC|                            |andrei@erdani.com

--
December 21, 2019
https://issues.dlang.org/show_bug.cgi?id=2482

berni44 <bugzilla@d-ecke.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@d-ecke.de

--- Comment #3 from berni44 <bugzilla@d-ecke.de> ---
I'm not sure at what place in the docs you'd like to see these functions mentioned. So I was not able to decide, if this issue is still valid.

--
December 21, 2019
https://issues.dlang.org/show_bug.cgi?id=2482

--- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> ---
So since this was opened (11 years ago!), the .sort property is gone. And AAs have been adjusted to require only opEquals and toHash.

Not only that but the compiler has been adjusted to complain if you define one but not the other.

See: https://dlang.org/spec/hash-map.html#using_struct_as_key

Which means if you don't use the right signature, it will complain anyway.

The only remaining thing that is an undisclosed issue is the TypeInfo methods that use these items (i.e. .getHash .compare .equals). These are affected if you define the right signature, and there will be no complaints if you don't use them in an AA.

Perhaps here: https://dlang.org/phobos/object.html#.TypeInfo

You could put notes about custom functions for the three methods on structs (classes are already required to override) and identify the "correct" signature that is guaranteed to be used. And you may want to research what DMD does, because I actually don't know the requirements.

--
December 21, 2019
https://issues.dlang.org/show_bug.cgi?id=2482

--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Actually, may be good to elaborate on the points in the AA docs.

I found that defining a toHash function without const makes it skip the function for xtoHash.

A note saying "Only the above signatures are guaranteed to work with AAs. If you change the signature in some way, it may not work"

Defining opEquals without const makes it fail to be an AA key.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=2482

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--