- From: Andy Seaborne <andy.seaborne@talis.com>
- Date: Fri, 13 Nov 2009 15:10:15 +0000
- To: Lee Feigenbaum <lee@thefigtrees.net>
- CC: RDF Data Access Working Group <public-rdf-dawg@w3.org>
On 13/11/2009 14:10, Lee Feigenbaum wrote: > Andy Seaborne wrote: >> >> >> On 13/11/2009 04:53, Lee Feigenbaum wrote: >>>> > ** ISSUE-39: Variable scope of alias variables >>>> > >>>> > Consensus that variables on the right-hand side of "AS" (alias >>>> variables) are not in scope for the rest of the query (including >>>> projected expressions), but not including outer queries of course. >>>> >>>> Disagree - this is an unnecessary restriction and results in needing >>>> addition nesting of SELECTs just to reuse an expression. >>> >>> What's an example of this? Does this only apply when an expression has >>> side-effects or does not evaluate the same when invoked twice? >> >> See the discussion around Holger's example - he uses the result of one >> expression in another >> >> In the SELECT case where the aggregate is in SELECT clause: >> >> SELECT (count(*) AS ?C) , (?Num/?C) >> >> It should also ways be possible to replace ?C by the expression used >> originally but as the expression becomes more complicated it becomes a >> nuisence. >> >> Nesting SELECTs has the effect: >> >> SELECT (?Num/?C) >> SELECT (count(*) AS ?C) >> >> so we can define the scope in the same way - left-to-right across the >> list of expressions - but it makes the feature non-critical. >> >>> This was driven in part, I believe, by what existing implementations did >>> that were discussed at the F2F. >> >> ARQ does it >> >> 'SELECT (1 as ?A) (?A+2 AS ?B) {}' >> >> --------- >> | A | B | >> ========= >> | 1 | 3 | >> --------- >> >> It didn't occur to me to not allow it but maybe that's the way the >> implementation works. There's a step which does one AS so multiple >> ones are just a sequence of these. >> >>> In an alternate design, what is the scope of alias variables? Where >>> can/can't they be used? >> >> A variable's scope across the select expression begins after the AS >> that mentions it. >> >> SELECT (?A+1 as ?A) {} >> >> The ?A in ?A+1 is out-of-scope. > > How does it work if the alias variable is used in the query pattern? The scope of "AS ?A" does not include the query pattern. Select expressions happen after matching (if the syntax were in the right order, it would be clearer. { ... } => SELECT (?x+1 as ?A) and it were written that way it would be clearer. Or as nesting: it's scope extends outwards, not inwards. SELECT (?A+1 AS ?B) SELECT (?x AS ?A) { <x> :p ?A } That leaves it whatever is right to do about SELECT (?x AS ?A) { <x> :p ?A } which is attempting to introduce a variable that is defined. That is an issue whatever the decision is the scope of select expressions across SELECT clauses. Andy > > Lee > >> Andy >> >>> >>> Lee >>> >>> ______________________________________________________________________ >>> This email has been scanned by the MessageLabs Email Security System. >>> For more information please visit http://www.messagelabs.com/email >>> ______________________________________________________________________ >> > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________
Received on Friday, 13 November 2009 15:10:25 UTC