|
1 | 1 | # JavaScript Records & Tuples Proposal
|
2 | 2 |
|
| 3 | +> [!IMPORTANT] |
| 4 | +> This proposal has been withdrawn [#394](https://github.com/tc39/proposal-record-tuple/issues/394) |
| 5 | +
|
| 6 | +---- |
| 7 | + |
3 | 8 | **Authors:**
|
4 | 9 |
|
5 | 10 | - Robin Ricard (Bloomberg)
|
|
17 | 22 | - Dan Ehrenberg (Bloomberg)
|
18 | 23 | - Maxwell Heiber
|
19 | 24 |
|
20 |
| -**Stage:** 2 |
| 25 | +**Stage:** Withdrawn |
21 | 26 |
|
22 | 27 | ### [Try out Record and Tuple in the playground!](https://rickbutton.github.io/record-tuple-playground)
|
23 | 28 |
|
@@ -56,14 +61,14 @@ Records and Tuples aim to be usable and understood with external typesystem supe
|
56 | 61 |
|
57 | 62 | Today, userland libraries implement similar concepts, such as [Immutable.js](https://immutable-js.github.io/immutable-js/). Also [a previous proposal](https://github.com/sebmarkbage/ecmascript-immutable-data-structures) has been attempted but abandoned because of the complexity of the proposal and lack of sufficient use cases.
|
58 | 63 |
|
59 |
| -This new proposal is still inspired by this previous proposal but introduces some significant changes: Record and Tuples are now deeply immutable. This property is fundamentally based on the observation that, in large projects, the risk of mixing immutable and mutable data structures grows as the amount of data being stored and passed around grows as well so you'll be more likely handling large record & tuple structures. This can introduce hard-to-find bugs. |
| 64 | +This new proposal is still inspired by this previous proposal but introduces some significant changes: Record and Tuples are now deeply immutable. This property is fundamentally based on the observation that, in large projects, the risk of mixing immutable and mutable data structures grows as the amount of data being stored and passed around grows as well so you'll be more likely to handle large record & tuple structures. This can introduce hard-to-find bugs. |
60 | 65 |
|
61 | 66 | As a built-in, deeply immutable data structure, this proposal also offers a few usability advantages compared to userland libraries:
|
62 | 67 | - Records and Tuples are easily introspectable in a debugger, while library provided immutable types are often hard to inspect as you have to inspect through data structure details.
|
63 |
| -- Because they're accessed through typical object and array idioms, no additional branching is needed in order to write a generic library that consumes both immutable and JS objects; with user libraries, method calls may be needed just in the immutable case. |
| 68 | +- Because they are accessed through typical object and array idioms, no additional branching is needed in order to write a generic library that consumes both immutable and JS objects; with user libraries, method calls may be needed just in the immutable case. |
64 | 69 | - We avoid cases where developers may expensively convert between regular JS objects and immutable structures, by making it easier to just always use the immutable ones.
|
65 | 70 |
|
66 |
| -[Immer](https://github.com/mweststrate/immer) is a notable approach to immutable data structures, and prescribes a pattern for manipulation through producers and reducers. It is not providing immutable data types however, as it generates frozen objects. This same pattern can be adapted to the structures defined in this proposal in addition to frozen objects. |
| 71 | +[Immer](https://github.com/mweststrate/immer) is a notable approach to immutable data structures, and prescribes a pattern for manipulation through producers and reducers. However, it is configurable if it generates frozen objects or not. This same pattern can be adapted to the structures defined in this proposal in addition to frozen objects. |
67 | 72 |
|
68 | 73 | Deep equality as defined in user libraries can vary significantly, in part due to possible references to mutable objects. By drawing a hard line about only deeply containing primitives, Records and Tuples, and recursing through the entire structure, this proposal defines simple, unified semantics for comparisons.
|
69 | 74 |
|
|
0 commit comments