qore
qore copied to clipboard
implicit index ($#) does not work with all loops and iterators
the documentation says:
The implicit index reference expression ($#) can be used whenever a list is iterated implicitly, such as with foreach statements and the map, foldl, foldr, and select operators.
nevertheless, using $# in a loop like:
SQLStatement stmt = table.getRowIterator(sql);
while (stmt.next()) {
hash row = stmt.fetchRow();
# something using $#
}
you always get $#=0 without any warning.
Such misuse took 2 days to discover, including crashes of qorus, debugging and a lot of lost time.
I think we should either support $# in anything that loops, or throw on any "misuse" of $# (at least upon a preprocessor directive).