Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

toString() should return the same for #{b, a} as #{a, b} #117

Closed
ajvincent opened this issue May 21, 2020 · 2 comments
Closed

toString() should return the same for #{b, a} as #{a, b} #117

ajvincent opened this issue May 21, 2020 · 2 comments

Comments

@ajvincent
Copy link

Just an observation. Since #{a, b} is logically equivalent to #{b, a}, you'll need a test to make sure that they return the same stringification, and may indeed want to specify that stringifying a Record means the keys are in a particular order.

Maybe the same for toPrimitive, valueOf cases.

@littledan
Copy link
Member

Yes, there will be no way to observe the differences. I'd expect toString() to print out the keys sorted in the same sort order we use for Reflect.ownKeys. I think this will become more clear when we have the draft spec text written, and just fall out of the semantics.

@rickbutton
Copy link
Member

Whether or not Record has non-null prototype that can hold a toString method is still up for debate in issue #71, but I think the answer to this question is the same regardless. Serialization/stringification of Records and Tuples will be deterministic for the same input value, and a record's properties are ordered, so the semantics of JSON.stringify mean that this will naturally happen, we won't need to do anything special here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants