Am 20.11.2016 um 20:35 schrieb Allin Cottrell:
On Sun, 20 Nov 2016, Sven Schreiber wrote:
> 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.
In all generality, I don't know. To me personally it has never occurred
to use the loop index outside the loop (well, except in the next loop,
again as the index).
Here's another example to consider. As things stand, the final
"print i"
fails in the following fragment unless the initial declaration is
uncommented:
...
endloop
print i
I think either way is defensible; you could say that i only exists
inside the loop, or you could say i lives on and keeps the value of the
final iteration. I guess I'm indifferent, as long as i is fully usable
inside the loop which is what I expected.
If we decide against default locality of the loop index, the
function
return case will solve itself. Otherwise it will need special treatment.
At least right now I don't see any argument against the non-locality --
also noting that already currently you may not use the loop index (say,
i) as a non-scalar type (say, matrix) _before_ the loop, because that
provokes a type mismatch error when getting to the "loop i=..." part. So
in that sense it's already kind of non-local.
thanks,
sven