gsdlab / clafer

Clafer is a lightweight modeling language
http://clafer.org
MIT License
45 stars 13 forks source link

allow self-explanatory parent expression #90

Open mantkiew opened 8 years ago

mantkiew commented 8 years ago

Often when navigating deeply nested hierarchies, it is not clear what is the target a parent expression is referring to. For example,

abstract A -> integer
    abstract B -> integer
        abstract C 
abstract D
    c -> C
    [ this.c.dref.parent.parent.dref ]

Instead, we could write the constraint a bit differently using the "self-explanatory parent":

[ this.c.dref.^B.^A.dref ]

which can be read "go through the reference c to a C, then to its parent B, then to its parent A, and through the reference". For now, the statement in this notation would simply desugar to the original expression; however, additional checks are now possible (whether the resulting target of the parent is indeed what the user intended).

mantkiew commented 8 years ago

Solution. For now, the syntax ^<id> should simply desugar to parent. Later, we should have a new IR element and use the identifier <id> during type checking.