ljharb / es-abstract

ECMAScript spec abstract operations.
MIT License
114 stars 30 forks source link

ECMA402 abstract methods #109

Open longlho opened 4 years ago

longlho commented 4 years ago

Hi there,

We wrote a lot of ECMA402 abstract ops for formatjs and I'm curious if the maintainers would be open to us moving things over here?

Thanks!

ljharb commented 4 years ago

That's a great question.

Currently it's only 262 methods, and it's split out by year. If we added 402, I'd want to also go back and add them for previous years.

In v2, the "manifest" exports will all be removed, so there wouldn't possibly be any bundle size increase from adding these - but in v1, every addition does add a cost for anyone importing an ES object.

If you'd be willing, sending a PR for all of the current ones would be great! However, instead of mixing them with 262 operations (since 402 also redefines some of them), what about adding an ecma402 top-level directory, and adding year folders in there?

longlho commented 4 years ago

kk I'll give that a try

mpcsh commented 4 years ago

@longlho would you be interested in coordinating on some of this work? I wrote half a polyfill of Intl.Segmenter as part of my stage 3 review; to turn it into an actual polyfill, I need to add a bunch of 402 methods to es-abstract. I'd love to work together!

longlho commented 4 years ago

Yeah definitely ;) some project management help to plan out the work & ofc actual contribution would be awesome!!

mpcsh commented 4 years ago

let's talk - are you on IRC? I don't see anyone with your username. alternately, feel free to DM me on twitter.

longlho commented 4 years ago

Btw adding 402 from previous years would be a huge amount of maintenance from what I've seen. Since ECMA402 correctness is "best-effort" and a ton of things are ILND (implementation-locale-numberingSystem-dependent) some stuff would have to be completely rewritten. For example: the algorithm to parse & validate locale changed recently in ES2020 where it used to be BCP47, now it's canonicalized UTS35 BCP47 which is a different algorithm.

ljharb commented 4 years ago

Sure, but we can start with just 2020, make it easy to add 2021, and then someone who's obsessive about completeness (hi!) can easily fill in older years over time.

longlho commented 4 years ago

hmm so our implementations of ecma402 uses TypeScript specifically since the InternalSlot declared in Formatters are very complex (e.g http://ecma-international.org/ecma-402/7.0/index.html#numberformat-objects is a 4-level nested attributes

diagram

So without TS it's very hard for me to maintain. I'm prob just gonna keep ecma402 abstract ops separately on top of es-abstract instead of merging this w/ this repo.

ljharb commented 4 years ago

Fair enough; let's keep this open in case you change your mind, or in case @mpcsh is still willing to contribute any AOs :-)