Skip to content
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

Objects with distinct field order do not compare equal #2341

Open
hostilefork opened this issue Jan 5, 2019 · 0 comments
Open

Objects with distinct field order do not compare equal #2341

hostilefork opened this issue Jan 5, 2019 · 0 comments

Comments

@hostilefork
Copy link
Member

While Rebol2 did not appear to try to compare object values field-by-field for equality, there exists code in R3-Alpha to do so (and apparently Red has it too):

>> x: make object! [a: 1 b: 2]
>> y: make object! [a: 1 b: 2]
>> x = y
== true

>> x: make object! [a: 1 b: 2]
>> y: make object! [a: 10 b: 20]
>> x = y
== false

However, neither R3-Alpha nor Red will do a check which takes order into account:

>> x: make object! [a: 1 b: 2]
>> y: make object! [b: 2 a: 1]
>> x = y
== false

If order is a distinct point of semantics in object equality, then that is a major issue. Attempts to hide the order (e.g. not to have PICK OBJ 2) may be misguided.

Note that JavaScript punts entirely on the idea of comparing objects field-by-field, forcing utility authors to implement an _.isEqual() function:

https://stackoverflow.com/questions/201183/how-to-determine-equality-for-two-javascript-objects

hostilefork added a commit to metaeducation/ren-c that referenced this issue Jan 6, 2019
Includes some cleanup of Equal_Context() done while looking at it.

See concerns added at:

metaeducation/rebol-issues#2341
hostilefork added a commit to metaeducation/ren-c that referenced this issue Jan 6, 2019
Includes some cleanup of Equal_Context() done while looking at it.

See concerns added at:

metaeducation/rebol-issues#2341
hostilefork added a commit to metaeducation/ren-c that referenced this issue Aug 3, 2020
Includes some cleanup of Equal_Context() done while looking at it.

See concerns added at:

metaeducation/rebol-issues#2341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant