We had this discussion before, but last week I ran into an example, which illustrates the problem. Let’s start with partial classes in C# as our common example:

PartialClass(c, ...): defines non-unique Class c scopes Field, Method

Here, non-unique has two effects: First, it allows multiple partial classes with the same name. Second, these share their scoped content. Now let’s have a look on rewrite rules. A natural specification would be:

Rule(r, ...): defines non-unique Rule r scopes Variable

However, this does not work, because all rules would share the scoped variables. A work-around can be an intermediate sort:

Rule(r, ...): defines non-unique Rule r
RuleBody(...): scopes Variable

The root cause are the two unrelated dimensions of meaning: Duplicates allowed/not allowed vs. scopes shares/not shared. I think duplicates should be expressed with (declarative) constraint rules, not with unique or non-unique. This makes the keywords simple scoping modifiers, distinguishing scopes which are shared (non-unique) or not (unique). However, the current syntax does not reflect that this is about scoping.

Submitted by Guido Wachsmuth on 22 July 2013 at 09:40

On 22 July 2013 at 09:40 Guido Wachsmuth tagged rfc

On 22 July 2013 at 09:41 Guido Wachsmuth tagged syntax

On 22 July 2013 at 17:59 Gabriël Konat commented:

I agree, maybe it should be defines shared Class c and default to non-shared.

On 22 July 2013 at 18:06 Guido Wachsmuth commented:

But this keeps it with the definition. But it is about two different kinds of scope (shared, non-shared).

On 22 July 2013 at 18:52 Gabriël Konat commented:

So this should be configurable per scope?

Also, we cannot just drop the unique part from the scope of definitions in our current infrastructure. If you have two functions with different properties, we need to assign these properties to unique URIs to distinguish between them.

On 20 May 2014 at 23:44 Guido Wachsmuth commented:

The issue is actually slightly different:

  1. Shared name with shared properties. This holds for partial classes, sorts in Stratego and SDF, and strategies and rewrite rules in Stratego.
  2. Shared name with shared scope. This holds for partial classes, but not for strategies and rewrite rules.

The issue is fixed in NaBL core:

PartialClass(c, _, _): defines non-unique Class c
PartialClass(c, p, _): Class c has parent p
PartialClass(c, _, _): Class c scopes Field at child nodes

Rule(r, _, _): defines non-unique Strategy r
Rule(r, lhs, rhs): Strategy r has type FunType(lty, rty) where lhs has type lty and rhs has type rty
Rule(r, _, _): new scope in Rule r scopes Variable at child nodes

Log in to post comments