Hi Sven,
sorry for the delay on this.
Am 09.03.20 um 19:22 schrieb Artur Tarassow:
Am 08.03.20 um 22:42 schrieb Sven Schreiber:
> Am 08.03.2020 um 20:18 schrieb Artur Tarassow:
>
>> changed early in the loop. Let me come up with a constructed example
>> -- I hope it shows my point for the usefulness of such a statement:
>
> I would agree that in some ways the hansl syntax is less flexible than
> that of other programming languages. However, I guess you need a
> better or "more sharpened" example.
Hi, I admit that the example isn't very convincing -- just supposed to
be a simple illustration of the issue.
> For example, I can rewrite your demonstration as follows:
>
>> <hansl>
>> scalar k = 2
>> loop i=1..3 -q
>>
>> scalar n = randgen1(i, 0, 3)
>> if n == 0
>> # get out here and proceed with i++
>> else
>> if n == 1
>> # get out here and proceed with i++
>> else
>> # do something clever here
>> if k > 2
>> # get out here and proceed with i++
>> else
>> # do something clever here
>> endif
>> endif
>> endif
>> endloop
>
> ...
> if n==0
> ...
> elif n==1
> ...
> elif k > 2
> ...
> else
> ...
> endif
>
> which is pretty clean without any 'continue' statement.
If it could always be solved like this, I guess their would be no need
for the "continue" statement in C ;-)
In principle, the continue statement is not needed to write workable
code. But it is a very convenient tool for writing more readable code.
Especially when code includes (many) nested if-statements.
I agree my example is not well chosen as it can be reduced to a few
simple lines as you have shown. But of course this is not always the
case. "continue" would make some stuff just simpler and _cleaner_ (more
logically structured) to write.
Best,
Artur