-
Notifications
You must be signed in to change notification settings - Fork 29
Object.is documentation #100
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
Conversation
According to Mozilla docs "In general, the only time Object.is special behavior towards zeros is likely to be of interest is in the pursuit of certain meta-programming schemes...suggested to avoid". |
This is looking great! Out traveling, but will try to review properly as soon as I can. |
src/Core__Object.res
Outdated
The `==` operator [is different in ReScript than Javascript](https://rescript-lang.org/docs/manual/latest/overview#boolean). Arrays, records and other non-primitives are equal if they have the same contents (deep equality). | ||
|
||
In ReScript, the `===` operator performs a strict equality check, like Javascript, and is similar but not identical to `is` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describing other functions and operators seem outside the scope of reference documentation. It will quickly become hard to maintain the documentation if it gets scattered across other definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks for the feedback.
src/Core__Object.res
Outdated
``` | ||
*/ | ||
@val | ||
external is: ('a, 'b) => bool = "Object.is" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this type signature makes sense. By definition you'd think that objects of different types wouldn't be considered identical, and you might as well weed that out at compile time.
There are of course exceptions, such as JSON-encoded primitives, but better to require explicitness than cater to convenience for weird edge cases I think.
I would therefore suggest this instead:
external is: ('a, 'b) => bool = "Object.is" | |
external is: ('a, 'a) => bool = "Object.is" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll change it.
Git problems here. I broke the tests because I uploaded the type signature change but forgot to remove tests that compare different types. I don't know how to fix it. Sorry! Do I do a git pull rebase? VS Code wants me to do a Sync but it isn't working. Not sure what steps to do in VS Code. Don't want to lose work here. Or you can fix it if it is easy for you. |
test updates
Ok fixed it. |
Consolidated into #117 |
Documentation for Object.is. Also some tests mostly so I could verify how it all works. Took the liberty of documenting some of
==
and===
at the same time. Read through the Mozilla docs and tried to summarize.