grammarware / software-evolution

Software Evolution
MIT License
1 stars 0 forks source link

LOOP statements #16

Open fake1244 opened 5 months ago

fake1244 commented 5 months ago

In LOOP statements, VARYING, WHILE and UNTIL clauses can be scattered across the body. However, my question is can there be multiple VARYING clauses or multiple WHILE or multiple UNTIL clauses? If the answer is yes what should be the control flow of such LOOP statement?

grammarware commented 5 months ago

According to the diagram, there can indeed be several clauses of each kind.

Just imagine each LOOP as one encompassing while(true) where different things are happening in the body. Then, for instance, each UNTIL X=0 can be compiled to an equivalent of if(x==0)break; — that happens at exactly the place where the UNTIL clause is found, not necessarily at the beginning or the end of the loop body, like in boring mainstream languages.