The role of unique/non-unique
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
Submitted by Guido Wachsmuth on 22 July 2013 at 09:40unique
ornon-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.
Issue Log
I agree, maybe it should be
defines shared Class c
and default to non-shared.
But this keeps it with the definition. But it is about two different kinds of scope (shared, non-shared).
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.
The issue is actually slightly different:
- Shared name with shared properties. This holds for partial classes, sorts in Stratego and SDF, and strategies and rewrite rules in Stratego.
- 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