This follows up on the thread started by Artur at
https://www.mail-archive.com/gretl-devel@gretlml.univpm.it/msg10198.html
Since "foreach" loops are advertised as working via string
substitution, it seems they really ought to work for arrays of
strings, and that's now in git. Trivial example follows:
<hansl>
strings S = defarray("tea", "coffee", "schnapps")
loop foreach i S -q
print "Would you like $i?"
endloop
</hansl>
It's not clear to me that it's desirable to extend this to arrays of
other types, nor what that would actually involve in terms of the
usability (or otherwise) of "$i".
Here's one possible notion:
<hansl status="notional">
matrices MM = defarray(I(3), mnormal(3,3))
loop foreach i MM -q
eval $i[1,1]
endloop
</hansl>
where we use string substitution to make "$i" come out as "MM[1]"
then "MM[2]". Personally, I don't find this at all appealing.
A second possible notion:
<hansl status="notional">
matrices MM = defarray(I(3), mnormal(3,3))
loop foreach i MM -q
eval MM[i][1,1]
endloop
</hansl>
In this case we don't mess with supporting string substitution for
arrays of matrices but just let "foreach i MM" stand as shorthand
for "i=1..nelem(MM)", thereby saving 2 keystrokes. Meh.
Allin