There seem to be two issues with non-transitive scoping in Spoofax 1.2:

  • when used in combination with non-anonymous scoping, it doesn’t seem to change the behavior of name binding. This is probably a regression.
  • when used in combination with anonymous scoping (e.g. UnionScope(_): non-transitively scopes Var), no Stratego code is generated. This may be something that was never supported.

My use case in SPARQL 1.1 is as follows (note: # starts a single line comment):

SELECT *
WHERE {
  FILTER (?a = 3)    # usage of "a"; "a" is visible here; no error
  ?a ?b ?c           # definitions of variables "a", "b" and "c"
  FILTER (?d = 3)    # usage of "d"; "d" is visible here; no error

  {
    ?d ?e ?f         # definitions of variables "d", "e" and "f"
    FILTER (?a = 3)  # usage of "a"; "a" is NOT visible here; error
    FILTER (?d = 3)  # usage of "d"; "d" is visible here; no error
    FILTER (?g = 3)  # usage of "g"; "g" is NOT visible here; error
  } UNION {
    ?g ?h ?i         # definitions of variables "g", "h" and "i"
  }
}

The way I thought of solving it, is by collecting all variable definitions inside the three UNION blocks (in this case a, b and c) and adding them to the WHERE clause using Stratego transformation, such that they are visible in the outer scope, just like d, e and f. Then I wanted to make the UNION non-transitively scope variables, such that e.g. variables a, b and c are visible in the second UNION block, but not in the first and third.

Essentially, I need a way to hide names from an outer scope.

Submitted by Oskar van Rest on 19 September 2014 at 00:30

On 12 January 2015 at 03:52 Guido Wachsmuth commented:

Like the issue with contextual scoping, this one is also caused by the last changes to the scoping rules generator.

Log in to post comments