New Issue: Should we have non param numBits\numBytes functions?

19364, "stonea", "Should we have non param numBits\numBytes functions?", "2022-03-04T22:23:19Z"

This is something that came up during the types module review (https://github.com/Cray/chapel-private/issues/3034)

The following functions are used to query information about the size of a type:

  proc numBits(type t) param
  proc numBytes(type t) param

As of today these only work with numeric and fixed width bool types. However I think users would find it useful for these to work with any arbitrary type\record\class\etc.

During the meeting it was mentioned that historically it was hard to get this info out of the C compiler, even though sizeof is compile time, because we don't get the actual param size in the chpl compiler.

It seems like we could do this at runtime however.

We ran a stroll poll in the meeting to gauge how people felt about this:

  poll about sizeof and numBits/numBytes and whether they are param or not
  * 3 I would be fine if sizeof() returned a non-param
  * 0 it should be named something else if it isn't param-returning
  * 3 fine if the non-param size queries were also called numBits and didn't return params
    * the caller could specify `param p = numBytes(t)` if they wanted the compile to fail if you didn't get a param back