-
Notifications
You must be signed in to change notification settings - Fork 179
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
Constructor Options Bag normalization #5839
Comments
About LocaleMatcher specifically: this only affects data loading, right? I don't think most individual component constructors will have anything special to do with LocaleMatcher except for passing it down to the data provider. Things that are passed down to the data provider can be done externally via a custom data provider. This is just to say that I don't think LocaleMatcher by itself is a very strong argument in favor of requiring options. What we've done in the past, and what I lean toward doing here, is to keep |
That's a great point. Basically we can handle ECMA-402 locale matcher even by something like: let provider;
provider.setLocaleMatcherStrategy(LocaleMatcherStrategy::Foo);
let dtf = FooFormatter::try_new(provider, preferences); this way we don't need it in Options.
Yes, I'd like us to decide if we are ok having effectively three patterns for runtime arguments: 1) no arguments, 2) options bag, 3) single option. One half-way convergence would be to migrate (3) to (2) and have only two scenarios. |
I think the following choices are fine:
Things we should not approve:
|
Thanks! Here's a list of cases that do not follow your heuristics:
|
Thoughts:
|
In #5852 I
Left:
|
Split segmenter discussion into #5856. Opened and merged a PR for AnyCalendar. The experimental components can be discussed as they continue to iterate. I don't think we need separate issues for them. |
Partially fixes #5839 --------- Co-authored-by: Shane F. Carr <[email protected]>
With introduction of Preferences we now have the final shape of the first argument to constructors and implemented the normalized model for how to converge Locale and Preferences.
The remaining question is how to handle the second argument which we currently have three approaches to:
OptionsBag
, similar toPreferencesBag
but for developer-induced optionsIt looks like this:
We have an opportunity to normalize it and conform all constructors to Option 1, if we want to, but it doesn't feel like a natural obvious choice, so I'd like to discuss it.
How we modeled preferences, locales and options
The current architecture separates
Preferences
which represent user-provided values fromOptions
which represent developer-provided values.This is novel and different from how ECMA-402 handles the constructors. In ECMA-402 we have
(locale, options)
pair where Options is a bag combining keys set by user and developer and the user-ones get merged with locale extension keys.In our model the Preferences and Locale get merged as they represent the user-driven keys, and the Options are split into two "types".
First type are options that are affecting data slicing. In that case we push them to the constructor itself to allow for DCE to remove unnecessary code. Second type is options that don't affect DCE. It looks like this:
Value proposition of normalization
If we were to normalize the second argument I see three main value props:
localeMatcher
Why we shouldn't do this
There are several reasons for which we may not want to normalize it:
Default::default()
,None
oroptions!{}
to each constructor just to have consistency may not be worth it.LocaleMatcher
has questionable value, is basically never used and while we may have to find a way to support it, it is not clear if we should design ICU4X component API around it just becauseLocaleMatcher
exists.Counters:
Option<OptionsBag>
to allow forNone
if we think it's better DX thanDefault::default()
.LocaleMatcher
(to pass test-262) then we have to find a way to pass this argument to each constructor somehow... Even if no other Options are needed by that constructor.Is it urgent?
I'm not sure if it is. It would be nice to have a consistent, ECMA-402 compatible, constructor story for 2.0 and the PR is going to be quite simple to write if we decide to go for it, but it may be that we have different opinions and should give ourselves time to think it through and plan this for 3.0.
The text was updated successfully, but these errors were encountered: