Repository navigation
doc: add CompareOptions.filterer
#18
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
Open
JakobJingleheimer
wants to merge
1
commit into
main
Choose a base branch
from
doc/add-filterer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What inputs are expected for
aandb? If they're values in the object graph, then how does a filterer differentiateor just in general, where in the graph its invocation relates to?
Uh oh!
There was an error while loading. Please reload this page.
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.
Ah, yes, I suppose the type of
AandBare notunknown: they're a primitive (or "special" key). And a couple things are missing.So I guess the type would be more like:
For descriptor, I think we already covered this:
Aand/orBwould have that special key inpath(which was missing before, so that probably created the confusion).RE the "special" path segment, what about a well-known symbol, like
Symbol(Deviation:Descriptor)&Symbol(Deviation:Prototype)(orSymbol(DescriptorDeviation)&Symbol(PrototypeDeviation))? I think I'd prefer the:delimited version.Thoughts on
mismatch→unequal,equality, or maybe even the equality algo used likesame-zero?mismatchseems a little "shit happened" to me 😅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.
The special path segment can't be a symbol, because any such symbol could itself be an actual property key—e.g.,
{ foo: { [Symbol(DescriptorDeviation)]: { value: 42 } } }would have an value-mode path like["foo", Symbol(DescriptorDeviation), "value"]which could not be distinguished from a similar descriptor-mode path for{ foo: 42 }.Yeah, I don't love "mismatch" either. "unequal" works for me.
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.
Symbols are unique though, so
Symbol(foo) ≠ Symbol(foo). If the symbol we use is well-known, it can be checked and there is no collision.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.
You can't stop someone from extracting that symbol and using it as a property key.
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.
Ahh. That's true… but then they clearly effed up, no? They broke themselves.
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.
This claim is true but irrelevant here; we're talking about an array of property keys so objects are in fact available as sentinels.
No, that's not clear at all. I am not willing to write off such use as "broken".
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 believe there is no legitimate use-case for a user to pass an object containing our own symbol to
compare.Uh oh!
There was an error while loading. Please reload this page.
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.
Here's one: verification that an actual
Symbolbuilt-in matches expectations. There are multiple ways to do accomplish this, but at least one of them involves using the object itself (e.g.,compare(globalThis.Symbol, expectedSymbol)).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.
"Legitimate" isn't really relevant (although I can come up with some) - if it is possible, we have to define behavior for it, and having a special sentinel value produce confusing results just isn't viable.
A library can arbitrarily declare a subset of value types are valid, but the language can not.