-
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
Quad interface: when does equals return true? #133
Comments
I agree -- this also justifies removing the falsy tests from the data model since |
Not quite. The interface says that the first parameter should be a quad, but this is not enforceable at design time in JavaScript. Hence, it should be checked at runtime, and can return false.
It's not, but is possible to pass it, and as such, we need to deal with it. We can define the fist argument of |
This is usually where having a Typescript definition just for the interface is useful -- if you type check everything at runtime then your library will become a bloated mess. Better to advise the use of strong types in the documentation or in a Either way, this should definitely be discussed and documented. Until then, the test suite should be agnostic towards this IMO. |
Agreed, but this is JavaScript 🙂 |
@RubenVerborgh wrote:
Ok, if i understand your feedback correctly, you want (a) to remain, to ensure the Quad type in JavaScript. I am asking, because in PHP one can enforce the type of a parameter. So it seems (a) only applies, if that's not possible. I also support @blake-regalia 's statement about Typescript. Its a specification for JavaScript, but this TS definition be a handy addition for many developers. |
In #129 we have link to typescript definitions for RDFJS, we could possibly make it more prominent and all the team members using TS could review those definitions. |
Shall we make a decision on this? I'm strongly in favor of checking at runtime and returning false. |
Let's discuss on the call. |
Link please? |
Sorry to extend this issue even more but i'm afraid there is actually another problem this invites which we have not discussed (my apologies for not preparing enough before the call). Namely, if the assumption is to return true or false no matter the type, then we would also have to check for falsy values on each component of the quad, otherwise it could throw (depending on impl -- in fact, the current test suite included) in these circumstances: factory.quad(s, p, o, g).equals({
subject: null,
predicate: null,
object: null,
graph: null,
}); In the end,
That is in addition to comparing each termType and value (16 in total):
|
@blake-regalia Not a problem for #142, because the null/undefined test of the fields is performed as part of the |
@RubenVerborgh Not so fast -- if you have a look at the current test suite code i linked to it actually relies on |
The reference implementation you linked to does not yet follow my proposal in #142 and indeed fails because of that. |
Okay great -- the PR did not yet have the Quad commit when i last commented; will review shortly. |
The spec says:
The only parameter is of type
Quad
, therefore (a) is always right, isn't it? Or what is meant with "of the same type"?If my assumption is right, i would suggest removing the (a) part from the text.
(ref #130)
The text was updated successfully, but these errors were encountered: