ecma402
ecma402 copied to clipboard
Editorial: Refactor PartitionPattern for simplicity and comprehensibility
trafficstars
- Adds a prose description explaining treatment of brace-wrapped placeholders and adjacent literal text in converting a String pattern into an equivalent List of Records.
- Renames spec aliases (beginIndex → placeholderStart, endIndex → placeholderEnd, p → placeholderName).
- Adopts ECMA-262 phrasing conventions (e.g., "the substring of S from inclusiveStart [to exclusiveEnd]" and
</≤/≥/>operators). - Reduces unnecessary repetition (e.g., "If beginIndex > nextIndex, then Let literal be the substring of pattern from nextIndex to beginIndex and Append the Record { [[Type]]: "literal", [[Value]]: literal } to result." → "Let literal be the substring of pattern from placeholderEnd + 1 to placeholderStart and If literal is not the empty String, then Append the Record { [[Type]]: "literal", [[Value]]: literal } to result.").
- Makes more obvious the omission of zero-length literal Records.
- Increases alias reference locality (e.g., checking for a literal part between a previous placeholderEnd
}and current placeholderStart{before advancing placeholderEnd for the current placeholder part).
@ryzokuken ping