Open bradcray opened 3 years ago
I believe Type module is a good fit compared to to other modules for this problem, if it is going to support in the future other types like arrays, tuples,etc.. I believe it should have a dedicated module for it, or they could be added in a related way to each other.
For example, we can bundle all functions together.
proc getDynamicClass(expr) {
return __primitive("class name by id",
__primitive("getcid", expr.borrow())
):string;
}
proc getDynamicArray(expr) {
}
Note that where my OP above has sketched out what this capability might look like for classes, @12mohaned has developed a branch that does similarly for arrays in #17591.
I'm finding that running the workaround in the compiler today, we're getting a warning about use of c_string
, which is deprecated, which I think suggests that the primitive itself is using c_string
rather than c_ptr(c_char))
. I'm wondering whether this would be a simple fix in Dyno.
Within the code base, we have the ability to get the dynamic type of a class as a string, and this can be nice from a debugging / I/O perspective, however, it is not currently a user-facing feature. Doing so seems like a nice utility, where the hard questions are:
For example, a very trivial implementation might look like:
and a more complex version might look like:
(where ultimately we might extend this to support non-class types as well? E.g., by printing out the static type for simple value types, information about arrays for arrays?)