- From: Nathan <nathan@webr3.org>
- Date: Thu, 28 Apr 2011 19:31:10 +0100
- To: Ivan Herman <ivan@w3.org>
- CC: benjamin.adrian@dfki.de, RDFa WG <public-rdfa-wg@w3.org>, Manu Sporny <msporny@digitalbazaar.com>
Ivan Herman wrote: > On Apr 28, 2011, at 17:48 , Benjamin Adrian wrote: > >> Hi, >> >> I just want to summarise the problems I had with BlankNodes while >> implementing the following methods: >> >> - BlankNodes.equals(RDFNode) >> - Graph.import(graph) >> - Graph.merge(graph) >> >> As BlankNodes are only valid within the scope of a single Graph, >> I felt it hard to implement whether two BlankNodes are the same or not >> without having any graph scope defined in the RDF API. >> >> Ivan proposed to add the following: >> >> pass a graph reference in the factory method >> * BlankNode createBlankNode(graph); >> >> add a graph reference in BlankNode. >> [NoInterfaceObject] >> interface BlankNode : RDFNode { >> readonly attribute Graph graph; >> readonly attribute any value; >> }; >> >> Now, BlankNode.equals(node) can check for the graph the BlankNode was >> defined in. >> >> The problem with this solution is that we then need to define a >> Graph.equals(graph) method. > > That I do not really understand, but that may be my Javascript incompetence. > > If I create a Graph in a programming language, it has some sort of a 'handle'. It is not an identifier in the URI sense, it is, shall we say, pointer to an object in the good old C/C++ sense. That is what is stored in the Blank Node as a reference, and if these pointers are identical then, well, the blank node belongs to the same graph (or context, if you want). > > So what is the problem? I checked my libs (after wondering why this wasn't a problem for me) and found that I had implemented as follows: this.value = "_:b".concat(++api.BlankNode.NEXTID) that's inside the blank node constructor, then the equality test just checks if the values are equal. this gaurantees that each blank node in the environment has a unique id, and that two blank nodes are equal within that environment if they have the same id. certainly never had any problems with it (and I have used the code heavily), and it's also the way tabulator is implemented. likewise as per Ivan's note on references, two blank nodes are the same with a normal == test, since they can only be the same blank node if they are references to the same object. same thing from me then, I see no problem here. Best, Nathan
Received on Thursday, 28 April 2011 18:32:05 UTC