W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2012

Re: BIND Issue

From: Steve Harris <steve.harris@garlik.com>
Date: Tue, 21 Aug 2012 13:56:49 +0100
Cc: public-rdf-dawg@w3.org
Message-Id: <D05C5354-67DB-43D1-9AFA-2DC44D0466F4@garlik.com>
To: Andy Seaborne <andy.seaborne@epimorphics.com>
On 2012-08-21, at 13:19, Andy Seaborne wrote:
> 
> On 21/08/12 12:50, Steve Harris wrote:
>> On 2012-08-21, at 12:45, Andy Seaborne wrote:
>> 
>>> This is a brief summary of the BIND comment from Holger and Jeremy.
>>> 
>>> {
>>>   GRAPH ?g { ?s ?p ?o }
>>>   BIND(?o+1 AS ?o1)
>>> }
>>> 
>>> In Query/3LC, BIND operates on the proceeding basic graph pattern, and there is always a BGP, although sometimes it's empty (and invisible in the syntax).
>>> 
>>> This design means the introduced variable is minimally constrained by scope rules because the resulting expression is joined with the overall group elements.  The scope restriction of the applies only to the BGP.
>>> 
>>> This use of ?o1 is OK:
>>> 
>>> {
>>>   ?s :p ?o1
>>>   GRAPH ?g { ?s ?p ?o }
>>>   BIND(?o+1 AS ?o1)
>>> }
>>> 
>>> But there is an impact on the expression side of BIND - the scope of the ?o is reduced to the BGP as well.  So it is undef in the example.  The ?o is the GRAPH is not available until after the BIND is calculated.
>>> 
>>> In 1LC and 2LC BIND was translated to the algebra in the group pattern processing:
>>> 
>>>    If E is of the form BIND(expr AS var)
>>>        G := Extend(G, var, expr)
>>>        End
>>> 
>>> making the restriction scope of the var the whole of the preceding group up to that point and the same scope for the expression.  The new var and the expression scope will be the same in any design.
>>> 
>>> Filters still apply to the group but otherwise this is like writing a sub-SELECT (if we allowed * to be used like this:)
>>> 
>>> {
>>>  { SELECT * BIND(?o+1 AS ?o1)
>>>    {
>>>      ?s :p ?o1
>>>      GRAPH ?g { ?s ?p ?o }
>>>    }
>>>  }
>>> }
>>> 
>>> In 3LC, it is handled before that where BGPs and property paths are sorted out.
>>> 
>>> Proposal:
>>> 
>>> Restore the approach of the formal section of 1LC and 2LC.
>>> Clarify in the description section.
>> 
>> But the 1LC and 2LC BIND definition had some other undesirable side effect, that was less of a corner case, IIRC. Didn't we change it because of a comment?
> 
> 1LC and 2LC weren't very clear especially in the descriptive section. The idea was to be clear and with minimal impact.  3LC does not seem to have been "minimal impact" because of the expression scoping.
> 
> The only formal comment I can find is about a different matter (DB-8).
> 
> You might be remembering my "comments" that it was unclear, based on user feedback. It wasn't specifically about the design, just it was not clear.
> 
> What do current implementations do?  We can usefully be guided by those given the widespread implementation of SPARQl 1.1 already.

In 4store, it's an Extend and a Join - I don't honestly know in 5store.

I can't really tell what the scoping rules are in 4store though, it'a bit lax about that.

- Steve

-- 
Steve Harris, CTO
Garlik, a part of Experian
+44 7854 417 874  http://www.garlik.com/
Registered in England and Wales 653331 VAT # 887 1335 93
Registered office: Landmark House, Experian Way, Nottingham, Notts, NG80 1ZZ
Received on Tuesday, 21 August 2012 12:57:19 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:49 GMT