Given the following code

Class(
      "TA"
    , Extend([Extension("Student"), Extension("Staff")])
    , []
    )

I want to store

"TA" <sub: "Student"
"TA" <sub: "Staff"

There is no was to get “TA” in c in TS in the rule

Extension(s):-
    where store c <sub: s

Since there is no way in TS to ‘query upwards’.

Also: “TS has a limitation where references are not allowed on the left hand side of a relation, these must be definitions.”
Which means that desugaring to Extension(c, s) where c is a string or c is a reference will not work.

My question is, is the only way to let this work to make c in a desugared Extension(c, s) a non-unique definition?

Such that:

Class(
      "TA"{Def("/ System:S#0 / Class:TA /")}
    , Extend([
          Extension("TA"{Def("/ System:S#0 / Class:TA /")}, "Student"),
          Extension("TA"{Def("/ System:S#0 / Class:TA /")}, "Staff")
      ])
    , []
    )

Or is there a more elegant way to do this?

I guess I can also write my own traversal that grabs the correct id’s and stores the relation.

Submitted by Daco Harkes on 13 January 2015 at 18:23

On 13 January 2015 at 18:45 Daco Harkes commented:

Storing relations manually is rather trivial (seems better than using non-unique classes to solve this):

nabl-constraint(|ctx) = ?Class(c, Some(x@Extend(e*)), _);!e*;map(try(extends-add-subtyperel(|ctx,c)));fail

extends-add-subtyperel(|ctx, c) :
Extension(s) -> <fail>
where 
  <new-rel-tuple(|ctx, "<sub:", s)> c

Log in to post comments