Hi all,
from time to time I come up with nested if-else statements. I've
realized that code could be more readable if gretl would have a type of
the 'continue' command which is also known in C if I am not wrong.
The continue statement would continue with the next iteration of the
loop. This could also lead to less computation as the flow can be
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:
<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
# Example with 'continue'
loop i=1..3 -q
scalar n = randgen1(i, 0, 3)
if n == 0
continue
endif
if n == 1
continue
endif
if k > 2
continue
else
# do something clever here
endif
endloop
</hansl>
What do you think about this feature?
Best,
Artur