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

Add a built function refEqual<T>(a: T, b:T) to always compare ref equality #2668

Open
yjhmelody opened this issue Mar 10, 2023 · 2 comments
Open

Comments

@yjhmelody
Copy link
Contributor

yjhmelody commented Mar 10, 2023

Feature suggestion

When meet == operator overload. There is no way to know if the ref is same.

For reference type, it's very helpful to know the ref equality in many scenarios.
For value equality, we want to compare whether the values are equal. For example, as an index key, it is impossible to rely on comparison references, because the external key is newly constructed by itself.
But we still need the ref equality for such type.

BTW, use === to represent this sematic is fine.

@MaxGraey
Copy link
Member

What's wrong with this approach?

const isEqRefs = changetype<usize>(obj1) == changetype<usize>(obj2)

@yjhmelody
Copy link
Contributor Author

yjhmelody commented Mar 10, 2023

What's wrong with this approach?

const isEqRefs = changetype<usize>(obj1) == changetype<usize>(obj2)

its ok,but should be builtin

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

2 participants