#518: Record and Tuple ECMAScript Proposal
Discussions
2020-06-15
Tess: before this was raised as a design review with us, I raised this with idl and webidl... Both of those are being looked at. I think that's going fine. It will may result in one of them being renamed. If you have a webidl interface that accepts a webidl record, one of these ECMAScript records would work - so that might be fine. Overall I think it's great.
Ken: Yeah. I agree, looks great. At some point, spec authors would want to know what to use in their specs.
Tess: I think the open issues on webidl will cover that.
Ken: maybe we should update the design principle.
Tess: a lot of good browser vendor representation in TC39 but it's often people not as familiar with webidl.
Dan: can we close this?
Ken: I think we need to right a good answer to them.
[Tess to write a closing comment
OpenedMay 28, 2020
Hello TAG!
I'm requesting a TAG review of Record & Tuple.
This proposal introduces two new deeply immutable data structures to JavaScript:
Record
, a deeply immutable Object-like structure#{ x: 1, y: 2 }
Tuple
, a deeply immutable Array-like structure#[1, 2, 3, 4]
Records and Tuples can only contain primitives and other Records and Tuples. You could think of Records and Tuples as "compound primitives". By being thoroughly based on primitives, not objects, Records and Tuples are deeply immutable.
Records and Tuples support comfortable idioms for construction, manipulation and use, similar working with objects and Arrays. They are compared deeply by their contents, rather than by their shallow identity.
JavaScript engines may perform certain optimizations on construction, manipulation and comparison of Records and Tuples, analogous to the way Strings are often implemented in JS engines. (It should be understood, these optimizations are not guaranteed.)
Records and Tuples aim to be usable and understood with external typesystem supersets such as TypeScript or Flow.
Further details:
You should also know that...
We are interested where you would think that Record and Tuple would be a good fit for Web APIs and what work and/or precisions you'd need from us to use it. Please note that at the moment we do not have a way to create something analoguous to classes in that proposal. THis is being considered as a potential follow-on proposal.
We'd prefer the TAG provide feedback as:
🐛 open issues in our GitHub repo for each point of feedback