# New keyword 'then' as synonym for ','

**URL:** <https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213>\
**Category:** Uncategorized\
**Created:** [December 24, 2021, 8:01am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213 "2021-12-24T08:01:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![esb-dev](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/esb-dev/32/63_2.png) [@esb-dev](https://alloytools.discourse.group/u/esb-dev)\
**Post date:** [December 24, 2021, 8:01am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/1 "2021-12-24T08:01:11Z")

</div>

Alloy often has two notations for operators i.e. and/&&. Some people prefer the more verbose notation.  
I propose to introduce the operator “then” as a synonym for “,” the trace sequence operator.

I think in the code one has to add just one line in Alloy.lex

`"then" { return alloy_sym(yytext(), CompSym.TRCSEQ );}`

after line 234.

But one has to change documentation and It’s of course a question of the conceptual integrity of the language too. But imho it would fit.

–Burkhardt

---

<div class="post-metadata">

**Author:** ![peter.kriens](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/peter.kriens/32/3_2.png) [@peter.kriens](https://alloytools.discourse.group/u/peter.kriens)\
**Post date:** [December 24, 2021, 8:13am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/2 "2021-12-24T08:13:35Z")

</div>

This was a bug report so @grayswandyr, @DanielJackson @aleks and others please let us know what you think. Need a resolution on this. I’ve some time over the holidays so if there is a quick resolution I can do the update.

---

<div class="post-metadata">

**Author:** ![grayswandyr](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/grayswandyr/32/17_2.png) [@grayswandyr](https://alloytools.discourse.group/u/grayswandyr)\
**Post date:** [December 24, 2021, 9:29am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/3 "2021-12-24T09:29:57Z")

</div>

Hi,  
I see the rationale. I don’t have a definite opinion on the matter so I’ll just list pros and cons:

1. `;` is litterally a low-precedence right-associative `and after` so we already have, by definition, a verbose notation (`and after`);
2. on the other hand, low precedence with right-associativity is really the important bit here , so with `and after` the user must stack lots of parentheses and take care that they’re balanced, plus it’s not very readable.
3. `then` may be confusing because it evokes an `if/then/else` (which, by the way, some users would be happy to have);
4. it adds yet another keyword.

david

---

<div class="post-metadata">

**Author:** ![esb-dev](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/esb-dev/32/63_2.png) [@esb-dev](https://alloytools.discourse.group/u/esb-dev)\
**Post date:** [December 24, 2021, 11:17am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/4 "2021-12-24T11:17:43Z")

</div>

Hi,

agree with 3. Does anyone have a better and more appropriate term?

---

<div class="post-metadata">

**Author:** ![aleks](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/aleks/32/22_2.png) [@aleks](https://alloytools.discourse.group/u/aleks)\
**Post date:** [December 25, 2021, 6:17pm UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/5 "2021-12-25T18:17:11Z")

</div>

Can you provide some motivation for introducing this new keyword, i.e., something more significant than “some people prefer the more verbose notation”?

For example, can you provide a snippet of Alloy that you think would look better or more readable using the `then` notation?

---

<div class="post-metadata">

**Author:** ![esb-dev](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/esb-dev/32/63_2.png) [@esb-dev](https://alloytools.discourse.group/u/esb-dev)\
**Post date:** [December 26, 2021, 9:23am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/6 "2021-12-26T09:23:44Z")

</div>

The motivation for introducing `then` came from the following example.

```auto
/* Specification of a concrete scenario for
   the echo algorithm in Alloy using the specification in module echo_var
*/

// the specification of the algorithm with transition predicates initiate and so on
open echo_var

// the concrete example of a graph
pred exampleGraph [N0, N1, N2, N3, N4, N5, N6: Node] {
	Node = N0 + N1 + N2 + N3 + N4 + N5 + N6
	neighbors = N0->N2 + N0->N3 + 
              N1->N2 + N1->N3 +
              N2->N0 + N2->N1 + N2->N3 + N2->N4 +
              N3->N0 + N3->N1 + N3->N2 + N3->N4 + N3->N5 +
              N4->N2 + N4->N3 + N4->N6 +
              N5->N3 + N5->N6 +
              N6->N4 + N6->N5
}

// an explicitly given scenario 
run Scenario {
	some disj N0, N1, N2, N3, N4, N5, N6: Node {
		exampleGraph[N0, N1, N2, N3, N4, N5, N6]
		
		initiate[N2];
		forward[N0, N2];
		forward[N4, N2];
		forward[N3, N4]; 
		forward[N1, N3]; 
		forward[N6, N4]; 
		forward[N5, N3]; 
		echo[N5]; 
		echo[N6];
		echo[N1];
		echo[N3];
		echo[N4];
		echo[N0];
		echo[N2];
		always stutter
	}
} for 7 Node, 15 steps

```

Someone who’s first programming language was C (as in my case) or Java (as in my students case) seeing a semicolon ` ;` thinks of a sequence of assignments and statements, _not_ of a sequence of _states_. So I thaught, that something like this would better express what we mean:

```auto
   initiate[N2]
   then forward[N0, N2]
   then 
   ...
   then echo[N2]
   then always stutter

```

But I agree, it’s a minor point.

Kind regards  
Burkhardt

---

<div class="post-metadata">

**Author:** ![grayswandyr](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/grayswandyr/32/17_2.png) [@grayswandyr](https://alloytools.discourse.group/u/grayswandyr)\
**Post date:** [December 26, 2021, 2:00pm UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/7 "2021-12-26T14:00:20Z")

</div>

> [@esb-dev](#):
>
> Someone who’s first programming language was C (as in my case) or Java (as in my students case) seeing a semicolon ` ;` thinks of a sequence of assignments and statements, _not_ of a sequence of _states_ .

Notice that it doesn’t have to be _states_. Supposing you model events (call them _ev\_i_) using the [reified-event idiom](https://alloytools.discourse.group/t/modelling-a-state-machine-in-electrum-towards-alloy-6/88), you may describe a sequence of “instructions” (that is, events):

```auto
run { some ev_1; some ev_3; some ev_7 }

```

---

<div class="post-metadata">

**Author:** ![esb-dev](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/esb-dev/32/63_2.png) [@esb-dev](https://alloytools.discourse.group/u/esb-dev)\
**Post date:** [December 27, 2021, 7:39am UTC](https://alloytools.discourse.group/t/new-keyword-then-as-synonym-for/213/8 "2021-12-27T07:39:29Z")

</div>

I should have formulated more precisely: I would like the so-called “instructions” to be understood as specifications of a _sequence of state transitions_. That’s the case in David’s example too, isn’t it?
