bmw-software-engineering/trlc

new variadic function one_of

Closed this issue · 0 comments

It occurred to me that it would be convenient to have a new function one_of. For example:

type T {
   a optional Integer
   b optional Integer
   c optional Integer
}

checks T {
   one_of (a != null, b != null, c != null), "only one value may be set"
}

For two conditions you can use xor, i.e. a != null xor b != null but for three this is much harder right now:

checks T {
   a != null or b != null or c != null, "one value must be set"
   a != null implies not (b != null or c != null), "only one value may be set"
   b != null implies not (a != null or c != null), "only one value may be set"
   c != null implies not (a != null or b != null), "only one value may be set"
}

There are some implications:

  • need to allow variadic functions in the lrm
  • will need significant modelling in the linter