qore icon indicating copy to clipboard operation
qore copied to clipboard

implicit index ($#) does not work with all loops and iterators

Open pavelkveton opened this issue 8 years ago • 0 comments

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).

pavelkveton avatar Apr 29 '16 10:04 pavelkveton