-
Notifications
You must be signed in to change notification settings - Fork 110
Description
I believe currently the intended syntax for "refines" is something along the lines of:
(type $the_variant (variant
(case "x" unit)
(case "y" unit (refines "x"))
))Where the binary format for this is:
case ::= n:<name> t:<valtype> 0x0 => (case n t)
| n:<name> t:<valtype> 0x1 i:<u32> => (case n t (refines case-label[i]))
Personally I find this to be a bit of a discrepancy where in the text format a string is used ("x" above) and in the binary format an integer is used (the index of the case). This means that a text-to-binary and a binary-to-text implementation have to otherwise keep track of this information. For example implementing a text-to-binary translation means that the tool must perform resolution over the string names of each variant. Currently I don't think text-to-binary tools perform resolution over any string names at all, only over indexes (like $x). Additionally binary-to-text transforms may parse name sections to assist with printing debugging information throughout the text format but otherwise aren't required to perform this sort of index-to-string translation.
Could this perhaps be a case where the name of the case should be encoded for refines? Or othrewise could the text syntax use some sort of $id to reflect that index resolution is happening on it?