You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
A potential direction this proposal could take, which would solve a new set of problems, could be "upgradeable ArrayBuffers":
The new language primitive is a byte array (ArrayBuffer by value).
The primitive can be "upgraded" by applying a schema to access data.
Something sort-of like this...
letinput={a: 1,b: 2};// Convert the object to its immutable value typeletprimitive=Record.create(input);// Convert the immutable value type back to an object using a pattern schemaletoutput=primitive.upgrade({a: Number,b: Number});// Access a field without upgrading (for efficiency)primitive.get({a: Number,b: Number},`.a`)
What this achieves:
Immutability
Value Types
Equality is trivial (a byte comparison)
Hopefully easier to implement
Step toward zero-copy deserialization
Some initial open questions:
How to handle variable-length types in the record, like a String or a BigInt
Could allow one of these only in the final position (like Rust DSTs)
Or, variable-length fields could require a length prefix (but how is that represented?)
Syntax for how to access fields
Call site needs the whole schema; how can this be expressed ergonomically?