-
Notifications
You must be signed in to change notification settings - Fork 469
RFC: Protected value representation #6738
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
Comments
I will experiment with a new |
I ran a few more thought experiments, and here is the counter I found: Symbols are not sent out of bounds without explicit serialization. This potentially creates many problems in web environments with different context boundaries. For example, React RSC is sent from another boundary. React elements are included in the serialization because it is their knowledge, but there is no way to include ReScript-specific knowledge in the serialization. It all happens implicitly (unfortunately). As a result, any deriving comparison of it with values outside the boundary will fail and fallback to deep-equal. |
Closing this, |
I think we still need a way to determine which values are ReScript values, but we can't do that before a standardized serialization method. |
Uh oh!
There was an error while loading. Please reload this page.
Use symbol for internal value representation which should be protected.
Motivation
memo
rescript-react#111)Detailed Design
JavaScript has the standard method for this,
Symbol
These symbols are assigned to every "object" value that ReScript generates.
It is not assigned to primitive values such as string and number. They are already inherently immutable, and assigning to primitives will invalidate optimization in JS engines.
Record
Variants
Untagged variants
No changes
Assume they are explicitly opt-out.
Polymorphic variants
External values
FFI allows asserting unsafe values from outside. There are two options:
I prefer 2. There should be no cases where the ReScript type is coming from FFI.
Ser/de
TBD
If this cannot be solved, don't touch the current behavior. just adding it will increase the output size but no other problems.
Prior arts
The text was updated successfully, but these errors were encountered: