Properties and link predicates may contain multiple occurrences of the same expression. Consider this example (adapted from examples/formation1d.labs):
stigmergy Left {
link =
pos of c1 - pos of c2 > 0 and
pos of c1 - pos of c2 <= 5
#...
}
The translator simply emits the same C expression multiple times:
Properties and link predicates may contain multiple occurrences of the same expression. Consider this example (adapted from
examples/formation1d.labs
):The translator simply emits the same C expression multiple times:
Proposal
Introduce a new construct in the syntax of boolean expressions.
Bexpr = true | false | Bexpr and Bexpr | Bexpr or Bexpr | let KEYNAME = Expr in Bexpr
where KEYNAME is a valid and unused variable identifier (alphanumeric, starts with lowercase). The example therefore becomes:
This improves the readability of the specification and may also allow to generate simpler C code: