-
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
Proposal: remove equals method #150
Comments
I vote 👎 because our goal with RDF/JS is to make an idiomatic JavaScript API. In such APIs, objects can have properties, methods, etc. The idiomatic OO way to check for equality, in absence of operator overloading, is a member method. Also, there are zero use case for using "plain objects", not even for exchange, given that better serialization formats for RDF exist. We should not aim to invent another RDF serialization. |
I vote 👍 because I see different implementers having mutually exclusive expectations to how such member method should work (chat comment). As I understand implementations can still provide such custom member method behaving as this implementation expects, at the same time libraries which aim to work only based on what the spec defines can still use a function of their choice which will behave in a way they expect. (EDIT: It all depends on resolution of #151 ) I think we still haven't documented how different data factories supposed coexist (eg. https://github.com/rdfjs/representation-task-force/issues/79#issuecomment-457259704) and haven't followed up on converting instances created with one factory to instances of another factory #137 Possibly having more clarity in that aspect will allow implementers to evaluate difference between having a 'blessed'
👍 |
This comment has been minimized.
This comment has been minimized.
I vote 👍 because the API should have correct semantics. The current proposal is incorrect to define Example. Suppose that an implementation used persistent data structures to support reference equality for comparison. That would work only for values that it constructed, but would fail for values constructed by others. In supporting this kind of specialization, the current proposal assumes that "interop" means cross-runtime interop, neglecting shared-runtime interop. Incidentally, values and mechanisms have distinct semantics, and JS does in fact have API's that use plain objects to represent plain data, which is what RDF structures are. For example, the iterator protocol uses plain |
Sorry for being the annoying one here 🙂 Case in point:
I have a very good point, and that point is performance: So I am exactly doing what you are saying here:
but
is incorrect because there obviously is a (slower) fallback path. So definitely registering your vote, but those three particular arguments might need stronger evidence. |
I tend to agree with @elf-pavlik. In #144 I pointed out that I feel better about |
More votes? @blake-regalia? Others? |
Equality between terms is a a pretty fundamental function and if you can't get interoperability between versions on this, then hope to actually be able to interchange libraries seems far off. rdflib.js used to use sameTerm() but has been changing that to equals() to follow this spec. If @elf-pavlik by "libraries which aim to work only based on what the spec defines can still use a function of their choice which will behave in a way they expect." you mean libraries using this API will have to have implementation aware code then that would be failure - or do I misunderstand? |
@RubenVerborgh, thanks for your thoughtful critique, and indeed for opening this issue. For context, I am working on a system where independent components can communicate intent, capabilities, and other metadata (y'know, semantic web) to support visibility, portability, composition, tooling, etc. RDF is the obvious choice for this. In some cases this will involve small, standalone functions that do one specific thing, and could themselves be defined as RDF literals (with a type indicating they are JS code). It would be preferable if such functions could emit usable triples without any outside references. I would maintain that Yes, there can be performance or other reasons for wanting to use reference identity for comparison. I have run into a case, using rdf.js terms with @thi.ng/rstream-query, which uses reference identity (before falling back to value comparison). That fallback would work in principle, but I also want to extend the terms with additional properties (e.g. runtime value). However, you can still do these optimized comparisons using static (or ad-hoc) methods. Note that even your N3 implementation (which is full of good ideas) never depends on the I don't agree that The OP is to remove |
I meant that some libraries (we could think of them 'lower lever') will choose to only rely on the core Other applications (we could think of them 'higher level') may choose an implementation of data factory which provides some convenient extensions to complement the minimal spec. In that case, application will expect that all instances get created with that specific data factory and sometimes it may need to convert instances created by other factories #137. #79 also plays role here since it can allow application to provide its preferred data factory as soon as possible and this way minimize need for conversion. So far we don't have anything on this page: https://github.com/rdfjs/representation-task-force/wiki/Additional-properties but i might seen some custom extensions in various factories
We might need to clarify our strategy for
|
Disregarding the operator overloading part, I agree that the idiomatic way for comparing values in these cases is to use instance methods, e.g.,
I completely disagree. re @gavinpc-mindgrub
and @timbl
I think this thread may have accidentally conflated "remove equals" with "move equals to static method" and its possible some of the thumbs down votes are merely against the former? Me: I have mixed feelings about this. IMO, @elf-pavlik makes a lot of good points even if a static method would be the "less idiomatic" way. I think it's dangerous to just defend with "my way is more idiomatic" if there are actual considerations for the alternative. A static method would indeed offer more potential benefits than an instance method, including not having to worry about the ordering of two subjects for comparison, e.g., |
There was enough time to exchange up arguments. Let's close this issue. Based on 2 👍 and 8 👎 votes: RESOLVED: We keep the |
@bergos Is voting on this really the best way to come to a consensus? My argument is a bit more nuanced than just a simple up or down vote. |
@bergos I would also add that per @blake-regalia's comment above, it may not have been clear what was being voted on. The definition of equality is clear, the spec defines it, and implementations should include it. The objection leading to this issue (#104) was just about the fact that requiring instance methods (any instance methods) means that ad hoc objects (such as |
@awwright The best way would have been to propose one or more other options to vote for, like we did it in #151, early after this issue was opened. But at some point we have to accept what the majority voted for doesn't go in that direction and discussing and voting again will not change the result.
@gavinpc-mindgrub I think it was clear what we voted on and just the comment by @elf-pavlik was unclear to @timbl . Also keep in mind that even in the same comment @timbl mentioned the |
For the record @rubensworks comment from rdfjs/stream-spec#16 (comment)
@rubensworks could you possibly share more details about problems you ran into? |
This issue illustrates an example of the difficulties that are encountered with the In summary, RDF quads are created in C++ world, which should then be transferred into JS world through the NAN interface. Note that I'm not saying that the |
Also, I've heard a similar argument for WebWorkers, which can only pass simple objects. (That said, I think it would/should be straightforward to slap a prototype on them.) |
I think this topic is a little bit bigger than just the The possibility to pass around a factory to get instances of About the plain object problem: Why not use a factory that creates instances like this: class NamedNode {
constructor (iri) {
this.plainObject = {
termType: 'NamedNode',
value: iri
}
}
get value () {
return this.plainObject .value
}
} If you need a plain object, just access Btw. the |
In #104, there was a suggestion to drop the
.equals
method fromTerm
andQuad
. Let's express opinions with arguments here. Please be clear and brief.Depends on #151: the assumption for including an
equals
method at all is that we come to an agreement of what it would look like in #151. Failure to reach such an agreement would likely also mean thatequals
has to be removed, regardless of the outcomes of this thread. So I would suggest to assume here that #151 succeeds with one of the three possible outcomes in there. If you disagree with any of those outcomes, #151 is probably be the right place.Please vote with 👍 or 👎 on this message.
The text was updated successfully, but these errors were encountered: