Author Topic: Conditional Do Loops  (Read 1405 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Conditional Do Loops
« on: September 07, 2020, 06:00:53 AM »

with head conditional:
Code: [Select]
int i
do while i<10
  i++
loop
print i

with tail conditional:
Code: [Select]
int i
do
  i++
loop while i<10
print i

Charles Pegge

  • Guest
Re: Conditional Do Loops
« Reply #1 on: September 07, 2020, 07:16:21 AM »
loop until is also supported. (this is decomposed to loop while not ...)

but do until is not yet supported. This will be in the next release (0.3.0)

JRS

  • Guest
Re: Conditional Do Loops
« Reply #2 on: September 07, 2020, 07:44:09 AM »

Nicola

  • Guest
Re: Conditional Do Loops
« Reply #3 on: September 08, 2020, 04:42:21 AM »
Hi.
I think a few things are needed for loops:
1) evaluate the condition first;
2) assess the condition at the end;
3) exit the loop in any place in the loop;
4) repeat the loop from any place in the loop itself.

1) while x = y ... wend;
2) Loop ... Until x = y;
3) Exit Loop;
4) Repeat Loop;

Hello.

Charles Pegge

  • Guest
Re: Conditional Do Loops
« Reply #4 on: September 09, 2020, 02:28:20 AM »
Our current conditional options are:
Code: [Select]
do while ...
  exit when/if ...
  continue when/while/if/until ...
loop while/when/if/until ...

They all decompose to:
Code: [Select]
do
  if ...
    exit/continue do
  endif
loop

JRS

  • Guest
Re: Conditional Do Loops
« Reply #5 on: September 09, 2020, 08:43:49 AM »
That surely seems to cover all the bases.

Nicola

  • Guest
Re: Conditional Do Loops
« Reply #6 on: September 10, 2020, 01:29:31 AM »
I think they are really ok. They satisfy all needs.
It is a good job. ;D