www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2729] New: hash_t undocumented and unnecessary

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2729

           Summary: hash_t undocumented and unnecessary
           Product: D
           Version: 2.025
          Platform: PC
               URL: http://www.digitalmars.com/d/2.0/arrays.html#associative
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jlquinn optonline.net


hash_t is listed as the output of *some* toHash() functions, without specifying
what it is.  The type is not defined, but the documentation expects programmers
to generate it anyway.  size_t is presumably the logical choice.

Since hash_t is being created by programmers, rather than being an opaque type,
I don't see where the value in having it is.


-- 
Mar 11 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2729






Additionally, the requirements for user-defined hashing for structs and classes
are inconsistent.

First, struct requirements are listed as needing 2 members:
  const uint toHash()
  const int opCmp(Keytype*)

Later, struct requirements are given again, but this time:
  hash_t toHash()
  bool opEquals(S) or bool opEquals(S*)
  int opCmp(S) or int opCmp(S*)

Classes are supposed to match the 2nd set of functions.

Shouldn't these functions be const?  And S should be replaced by "Keytype" or
the text above should state that S is a Keytype.


-- 
Mar 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2729






The value in hash_t is the self-documenting nature of it. It being called
size_t instead implies it contains a value with a different purpose.

But the page does need updating as to the rest of your comments, and I'll fix
it.


-- 
Mar 12 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2729


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 2.027


-- 
Apr 01 2009