(originally observed at #3918 (comment))
Top-level Phrasing Conventions:
- to create an untagged union of types,
- If all types are singletons, use
A (for 1 type), either A or B (for 2), or one of A, B, or C (for 3+)
- Else, use
an A (for 1 type), either an A or a B (for 2), or either an A, a B, or a C (for 3+) where all types with >1 inhabitant are listed before all singletons
Comparisons:
- when comparing for equality against multiple options,
- …
- consolidate
is/is not using either…or/neither…nor for a pair of options (e.g., x is neither option1 nor option2)
- consolidate
is/is not using one of for more than two options (e.g., x is not one of option1, option2, or option3)
While acknowledging that type comparison is not exactly the same thing as equality comparison, they are very similar, and the above guidance aligns for pairs (cf. "If x is either a String or a Number" vs. "If x is either true or false") and pure singletons (e.g., "If x is null" and "If x is either undefined or null" can be accurately classified into either category). However, they differ when the union grows beyond three members—"If x is either a String, a Number, or a BigInt" vs. "If x is one of ~foo~, ~bar~, or ~baz~".
This divergence causes unnecessary editorial friction, and I'd like to remove it in favor of common phrasing that is noted as such—and would propose the "one of" form. For the record, I count just 7 occurrences of "either an A, a B, or a C":
But if we instead decide to maintain the divergence, I'd like to clarify that the "untagged union of types" convention takes precedence over the "comparing for equality against multiple options" convention (e.g., "If x is either a String, +0𝔽, or -0𝔽" rather than "If x is one of a String, +0𝔽, or -0𝔽", essentially treating each individual value as an ad-hoc singleton type).
(originally observed at #3918 (comment))
Top-level Phrasing Conventions:
Comparisons:
While acknowledging that type comparison is not exactly the same thing as equality comparison, they are very similar, and the above guidance aligns for pairs (cf. "If x is either a String or a Number" vs. "If x is either true or false") and pure singletons (e.g., "If x is null" and "If x is either undefined or null" can be accurately classified into either category). However, they differ when the union grows beyond three members—"If x is either a String, a Number, or a BigInt" vs. "If x is one of ~foo~, ~bar~, or ~baz~".
This divergence causes unnecessary editorial friction, and I'd like to remove it in favor of common phrasing that is noted as such—and would propose the "one of" form. For the record, I count just 7 occurrences of "either an A, a B, or a C":
But if we instead decide to maintain the divergence, I'd like to clarify that the "untagged union of types" convention takes precedence over the "comparing for equality against multiple options" convention (e.g., "If x is either a String, +0𝔽, or -0𝔽" rather than "If x is one of a String, +0𝔽, or -0𝔽", essentially treating each individual value as an ad-hoc singleton type).