-
Notifications
You must be signed in to change notification settings - Fork 12
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
Rigorously define equals method on Term and Quad #142
Conversation
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.
👍
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.
Looks good to me. Just two minor comments.
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.
See comments
Checking for function is extra work; checking for truthy instead of true is less. I don’t mind though; let me know if you want true and I’ll change, I just don’t think it’s necessary to go the extra mile.
|
I don’t feel strongly, will just write true.
|
a81e910
to
afaaed8
Compare
All of the above comments have been addressed; please re-review as necessary. |
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.
+1 for the text, just some small Respec stuff. The comments should be valid for all added id
attributes and links.
There is still an outstanding edge case that is not covered by the algorithm which I brought up in my last comment; namely that factory.quad({
termType: 'NamedNode',
value: 'http://ex.org/s',
}, {
termType: 'NamedNode',
value: 'http://ex.org/p',
}, {
termType: 'NamedNode',
value: 'http://ex.org/o',
}, {
termType: 'NamedNode',
value: 'http://ex.org/g',
}).equals(other); might throw: |
@blake-regalia We are assuming now that they are valid Also see #137. |
afaaed8
to
b0ce7a6
Compare
@bergos' comments processed, pending @blake-regalia response. |
@RubenVerborgh By your own logic, iff we are assuming they are valid |
Null pointer exceptions are a common source of errors, I expect several magnitudes more common than malformed Term exceptions. |
Agreed - and I still think it would be nice to let devs know that the variable they passed to equals is actually
Well we are not just going for a majority of cases, it needs to be well-defined, consistent and fully-covered. |
Alright, not disagreeing, but I don't have more bandwidth to follow up on this. Re-assigning to @bergos and @blake-regalia, feel free to conclude in the way you think is most appropriate. |
I think this relates to #104 (Nuance "plain objects (JSON) cannot be used) since @blake-regalia just used such 'plain objects' to make his case. |
Removed commit `.equals parameters are optional and nullable`diff --git a/interface-spec.html b/interface-spec.html
index f0f7b01..5f4cc36 100644
--- a/interface-spec.html
+++ b/interface-spec.html
@@ -129,7 +129,7 @@
interface Term {
attribute string termType;
attribute string value;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -168,7 +168,7 @@
interface NamedNode : Term {
attribute string termType;
attribute string value;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -193,7 +193,7 @@
interface BlankNode : Term {
attribute string termType;
attribute string value;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -222,7 +222,7 @@
attribute string value;
attribute string language;
attribute NamedNode datatype;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -263,7 +263,7 @@
interface Variable : Term {
attribute string termType;
attribute string value;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -289,7 +289,7 @@
interface DefaultGraph : Term {
attribute string termType;
attribute string value;
- boolean equals(Term other);
+ boolean equals(optional Term? other);
};
</pre>
@@ -333,7 +333,7 @@
attribute Term predicate;
attribute Term object;
attribute Term graph;
- boolean equals(Quad other);
+ boolean equals(optional Quad? other);
};
</pre>
(Removed the commit, see it above) As for the other part I'm not sure to understand your suggestion @blake-regalia , let's start here:
Why this assumption? This PR so far doesn't let you throw when you implement Edited: the
(The spec defines the behaviour of @blake-regalia If I understand correctly you suggest explicitly mentioning that this behaviour is undefined? |
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.
For me it's ok, but boolean equals(optional Quad? other);
would be even better, as it's the exactly what's in the description.
@blake-regalia can you make a proposal what to change so the PR gets your approval? |
On the chat I suggested to reconsider if we really have to define standard (blessed) equal method or we better just leave for libraries to decide how to compare equality and implement it as utility functions: https://gitter.im/rdfjs/Representation-Task-Force?at=5c49de898ce4bb25b802ca8a
It also would allow some factories to use 'plain objects' discussed in #104 |
As I understand the problem @blake-regalia and @ericprud would like to have possibility to throw if I don't think having MAY or SHOULD helps here since this PR attempts to ensure that If we don't define |
Closing this concrete proposal until we reach an agreement here: #151 |
Reopening based on resolution of #151. |
@RubenVerborgh with current approvals I think you can just go ahead and merge it. |
I added @vhf for review as he had a good suggestion about the signatures. |
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.
While we're here, as per @vhf 's suggestion, it might be best to update the signatures as well, i.e., optional Term? other
and optional Quad? other
. @RubenVerborgh does that sound good to you? If so, let's try and add the commits to this PR.
No objection to that. |
@blake-regalia should we just apply patch @vhf posted in his comment above? #142 (comment) and do manual merge? |
Okay, made the commits -- let's wait for @vhf to review and then we can merge. |
Incorporate `optional .. ?` into IDL signature.
Closes #133.