-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: Refactor to replace camelCase slot and field names with PascalCase equivalents #770
Conversation
equivalent, carefully avoiding changes to observable behaviour which might be thereby generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better than the previous attempt, but is still running into similar issues. I think it will make the most sense to tackle fields piecemeal, leaving those subject to [[<_…>]]
dynamic lookup for last.
1. For each row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do | ||
1. Let _prop_ be the name given in the Property column of the row. | ||
1. If _bestFormat_ has a field [[<_prop_>]], then | ||
1. Let _p_ be _bestFormat_.[[<_prop_>]]. | ||
1. Let _first_ be the ASCII-uppercase of the substring of _prop_ from 0 to 1. | ||
1. Let _rest_ be the substring of prop from 1. | ||
1. Let _field_ be the string-concatenation of _first_ and _rest_. | ||
1. If _bestFormat_ has a field [[<_field_>]], then | ||
1. Let _p_ be _bestFormat_.[[<_field_>]]. | ||
1. Set _dateTimeFormat_'s internal slot whose name is the Internal Slot column of the row to _p_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new string manipulation and case-variant fallback makes me nervous, but I think it can now be dropped entirely (assuming field name capitalization and corresponding updates to DateTimeStyleFormat and BasicFormatMatcher and BestFitFormatMatcher.
1. For each row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do | |
1. Let _prop_ be the name given in the Property column of the row. | |
1. If _bestFormat_ has a field [[<_prop_>]], then | |
1. Let _p_ be _bestFormat_.[[<_prop_>]]. | |
1. Let _first_ be the ASCII-uppercase of the substring of _prop_ from 0 to 1. | |
1. Let _rest_ be the substring of prop from 1. | |
1. Let _field_ be the string-concatenation of _first_ and _rest_. | |
1. If _bestFormat_ has a field [[<_field_>]], then | |
1. Let _p_ be _bestFormat_.[[<_field_>]]. | |
1. Set _dateTimeFormat_'s internal slot whose name is the Internal Slot column of the row to _p_. | |
1. For each row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do | |
1. Let _name_ be the name given in the Internal Slot/Field column of the row. | |
1. If _bestFormat_ has a field whose name is _name_, then | |
1. Let _val_ be the value of the field of _bestFormat_ whose name is _name_. | |
1. Set _dateTimeFormat_'s internal slot whose name is _name_ to _val_. |
<li>A [[pattern]] field, whose value is a String value that contains for each of the date and time format component fields of the record a substring starting with *"{"*, followed by the name of the field, followed by *"}"*.</li> | ||
<li>If the record has an [[hour]] field, it must also have a [[pattern12]] field, whose value is a String value that, in addition to the substrings of the [[pattern]] field, contains at least one of the substrings *"{ampm}"* or *"{dayPeriod}"*.</li> | ||
<li>If the record has a [[year]] field, the [[pattern]] and [[pattern12]] values may contain the substrings *"{yearName}"* and *"{relatedYear}"*.</li> | ||
<li>A [[Pattern]] field, whose value is a String value that contains for each of the date and time format component fields of the record a substring starting with *"{"*, followed by the name of the field, followed by *"}"*.</li> | ||
<li>If the record has an [[Hour]] field, it must also have a [[Pattern12]] field, whose value is a String value that, in addition to the substrings of the [[Pattern]] field, contains at least one of the substrings *"{ampm}"* or *"{dayPeriod}"*.</li> | ||
<li>If the record has a [[Year]] field, the [[Pattern]] and [[Pattern12]] values may contain the substrings *"{yearName}"* and *"{relatedYear}"*.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, capitalizing the field names in [[LocaleData]].[[<locale>]].[[Formats]].[[<calendar>]] disrupts this and related mechanisms because of the coupling between field name and brace-enclosed field value substrings (e.g., an "{hour}:{minute} {ampm}" pattern is specifically referencing fields named [[hour]], [[minute]], and [[ampm]]). It's probably most expedient to leave alone any field named after a unit/date–time element/etc., unless you want to do a deeper dive on the format patterns and FormatDateTimePattern's transformation of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blast, I should have caught that! I'm guessing it's correct to assume that a deeper dive on FormatDateTimePattern should be understood as a very low priority.
<li>If the record has an [[hour]] field, it must also have a [[rangePatterns12]] field. Its value is similar to the Record in [[rangePatterns]], but it uses a String similar to [[pattern12]] for each part of the range pattern.</li> | ||
<li>If the record has a [[year]] field, the [[rangePatterns]] and [[rangePatterns12]] fields may contain range patterns where the [[Pattern]] values may contain the substrings *"{yearName}"* and *"{relatedYear}"*.</li> | ||
<li>If the record has an [[Hour]] field, it must also have a [[RangePatterns12]] field. Its value is similar to the Record in [[RangePatterns]], but it uses a String similar to [[Pattern12]] for each part of the range pattern.</li> | ||
<li>If the record has a [[Year]] field, the [[RangePatterns]] and [[RangePatterns12]] fields may contain range patterns where the [[Pattern]] values may contain the substrings *"{yearName}"* and *"{relatedYear}"*.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of the inconsistency; [[Year]] and {yearName} and {relatedYear} are elements of the same namespace even though they don't look like it.
1. Let _timeFormat_ be _styles_.[[TimeFormat]].[[<_timeStyle_>]]. | ||
1. Let _first_ be the ASCII-uppercase of the substring of _timeStyle_ from 0 to 1. | ||
1. Let _rest_ be the substring of _timeStyle_ from 1. | ||
1. Let _timeStyleField_ be the string-concatenation of _first_ and _rest_. | ||
1. Let _timeFormat_ be _styles_.[[TimeFormat]].[[<_timeStyleField_>]]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More string manipulation that we don't want in the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's best practice here -- table iteration when possible, or just accept that this is a place where by necessity 402 style guidelines must diverge from 262?
1. Assert: _styleFields_ is a Record (see <emu-xref href="#sec-Intl.DisplayNames-internal-slots"></emu-xref>). | ||
1. Set _displayNames_.[[Fields]] to _styleFields_. | ||
1. Return _displayNames_. | ||
</emu-alg> | ||
<emu-table id="table-displaynames-types"> | ||
<emu-caption>Fields Corresponding to Type Names</emu-caption> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, there must be a better way.
typo fix Co-authored-by: Richard Gibson <[email protected]>
table-iteration correction Co-authored-by: Richard Gibson <[email protected]>
Temperature check: would it be most appropriate to:
|
closed; abandoned for now |
fix #81
Changed slot/field names, carefully avoiding changes to observable behavior that could result from dynamic accesses to those slots. The only names left unchanged are two-letter names like [[co]] and [[nu]], and slots/fields only accessed dynamically.