Open acutmore opened 1 year ago
I've run into this and other ambiguities in the prose expressions of types described in structured headers several times. I'd bet the choice of using prose for types has cost us collectively a lot of time in thinking, nitpicking, discussing, and implementing rules in Ecmarkup. At what point is it worth it to switch to a precise, non-prose notation, such as List<Object | Symbol>? The exact choice of notation aside, this is what we likely have in mind anyway while we struggle to find a way to describe it in prose.
Some history: The spec used to have a less-prosey style that was (inconsistently) used for the declared type of record fields and internal slots. E.g., instead of an Object or *undefined*
, you might see Object | *undefined*
.
In PR #545, I suggested using this notation for the types of AO parameters + returns. @bterlson liked the idea, but the eventual decision was to use "assertion-style prose, rather than using an ad-hoc 'type signature'". (One benefit of this was that the ecmarkup processor could relatively easily generate a prosey preamble similar to what the spec already had.)
After the merge of PR #545 (and of follow-up PRs that spread structured headers to other kinds of operations), assertion-style prose became the dominant syntax for expressing 'types', so in PR #2602 and PR #2691, I used it to replace the less-prosey style mentioned above for declaring record fields and internal slots.
I think the only remnant of the less-prosey style is the notation for method signatures in the Essential Internal Methods table, which has been there since ES5.
Spun off from https://github.com/tc39/ecma262/pull/2777#discussion_r1089707394
Working on a PR that had "a List of either Objects or Symbols" prompted the following conversation with ChatGPT:
The intention of the PR is that the possibly empty list may contain both objects and symbols and may also contain only one of those types.
@jmdyck pointed out:
comment
Being clear and consistent about category of type this will help with automated type analysis of the spec.
Personally I quite like the idea of:
a List, where each element is either a T1 or a T2
.Thoughts?