www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16764] New: `hashOf` is misleading, error-prone, and useless


          Issue ID: 16764
           Summary: `hashOf` is misleading, error-prone, and useless
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com

In our root `object` module we have a function `hashOf` [1] with correct
definition: "to calculate hash of raw byte representation of given object" (at
posting time, see [2]).

This function should not be there because:
1. It is misleading (and as a result error-prone) because user doesn't expect
that logical object structure is not considered and this function operates with
raw representation bytes.
2. Has signature allowing incorrect usage (and as a result the function is
extremely error-prone).
3. It is not generally useful because primary purpose of hash functions is to
calculate hash of byte array with dynamic length (`void[]`) and this function
only accept data with size known at compilation time.

void main()

    real r;

and ignoring `toHash` function
    int[] arr = [1];

to length


Nov 24 2016