On Sun, 20 Nov 2016, Sven Schreiber wrote:
Am 20.11.2016 um 18:20 schrieb Allin Cottrell:
>
> I don't think this is new. The point is that if the index "i" is not
> declared outside of the loop it is considered an automatic variable
> which exists only for the scope of the loop. So you could get the
> effect you expected by sticking in
>
> scalar i
>
> before the loop. (Then the function will return 1).
So you don't think it's a bug? I mean the 'return' statement _is_
inside the loop where the loop index is declared.
OK, I think that point should carry it. But perhaps, before I try to
fix that particular issue, we should consider whether the policy of
making a non-predeclared loop index local to the loop is sound and
consistent with other aspects of hansl.
Here's another example to consider. As things stand, the final
"print i" fails in the following fragment unless the initial
declaration is uncommented:
<hansl>
# scalar i
loop i=1..2
print i
endloop
print i
</hansl>
If we decide against default locality of the loop index, the
function return case will solve itself. Otherwise it will need
special treatment.
Allin