Re: Concerning LET or AS

off list Steve and Lee encouraged me to be clearer about what I thought 
LET as a keyword means.

Here is my attempt at specifying it (based on the WG Wiki page).
Please note that I am not responsible for TopQuadrant's SPARQL work; 
Holger is our expert, and we tend to be dependent on Andy's implementation.
So, I am happy with any corrections from Andy.

It is not important how the word LET is spelt (i.e. as far as I know, 
TopQuadrant has no particular attachment to 'LET' rather than 'BIND' for 
example).

================================

In the FPWD of Query 1.1 we modify rule 43 for GroupGraphPattern as follows:

[43*] GroupGraphPattern ::= '{' GroupGraphPatternLetSub '}'

[A] GroupGraphPatternLetSub ::= ( GroupGraphPatternLetSub Let '.'? )? 
GroupGraphPatternSub

[B] Let ::= 'LET' '('  Var ':=' Expression  ( ','  Var ':=' Expression 
)* ')'

Rules [43*] [A] and [B] are interpreted by rewriting queries involving 
LET into queries
not involving LET.
We will use phi(x) to be the written query of x.

If x matches rule B, then:

phi(x) = 'SELECT' '(' * '(' Expression 'AS' Var ')' ( '(' Expression 
'AS' Var ')' )* ')'

(with the variables matching respectively).

If x matches rule A then

phi(x) =
phi(Let)
'WHERE' '{'
     phi(GroupGraphPatternLetSub)
'}'
GroupGraphPatternSub

The rest of the specification then applies.
==================

(Note this is a fine recipe for implementing as well).
Specifically, this prohibits forward references.
Being a macro expansion into a declarative form, this is declarative.

Jeremy

Received on Tuesday, 3 November 2009 22:52:13 UTC