@@ -116,9 +116,10 @@ def alignment_record(fields):
116116```
117117
118118As an optimization, ` variant ` discriminants are represented by the smallest integer
119- covering the number of cases in the variant. Depending on the payload type,
120- this can allow more compact representations of variants in memory. This smallest
121- integer type is selected by the following function, used above and below:
119+ covering the number of cases in the variant (with cases numbered in order from
120+ ` 0 ` to ` len(cases)-1 ` ). Depending on the payload type, this can allow more
121+ compact representations of variants in memory. This smallest integer type is
122+ selected by the following function, used above and below:
122123``` python
123124def alignment_variant (cases ):
124125 return max (alignment(discriminant_type(cases)), max_case_alignment(cases))
@@ -366,13 +367,13 @@ guaranteed to be a no-op on the first iteration because the record as
366367a whole starts out aligned (as asserted at the top of ` load ` ).
367368
368369Variants are loaded using the order of the cases in the type to determine the
369- case index. To support the subtyping allowed by ` refines ` , a lifted variant
370- value semantically includes a full ordered list of its ` refines ` case
371- labels so that the lowering code (defined below) can search this list to find a
372- case label it knows about. While the code below appears to perform case- label
373- lookup at runtime, a normal implementation can build the appropriate index
374- tables at compile-time so that variant-passing is always O(1) and not involving
375- string operations.
370+ case index, assigning ` 0 ` to the first case, ` 1 ` to the next case, etc. To
371+ support the subtyping allowed by ` refines ` , a lifted variant value semantically
372+ includes a full ordered list of its ` refines ` case labels so that the lowering
373+ code (defined below) can search this list to find a case label it knows about.
374+ While the code below appears to perform case-label lookup at runtime, a normal
375+ implementation can build the appropriate index tables at compile-time so that
376+ variant-passing is always O(1) and not involving string operations.
376377``` python
377378def load_variant (opts , ptr , cases ):
378379 disc_size = size(discriminant_type(cases))
0 commit comments