On Sun, 16 Jun 2019, Artur Tarassow wrote:
I really like the C-style if-else syntax as well as the C-style
'++' and '--'
operators for incrementing and decrementing a number, respectively. But I am
surprised to see that the following does not work:
<hansl>
scalar s = 0
loop i=1..2 -q
catch s = (i==1) ? 1 : +1 # no effect
s
catch s = (i==1) ? 1 : s++ # no effect
s
catch s = (i==1) ? 1 : s+1 # works as intended
s
endloop
</hansl>
Why is the 2nd approach not working here?
According to the C standard an operation such as
s = s++
leads to undefined behavior. In general, "s++" means, yield the
current value of s then increment s, but with s itself on the left
it's not clear what has to be done. So, not a gretl bug.
Allin