|
On Nov 3, 2009, at 3:33 AM, Roberto Ierusalimschy wrote:
I am sorry, but I sent a wrong reply. I thought his proposal was to have an extra hidden (but unique) control variable before the visible variables in the loop. That is, the statement for a,b,c in exp do would be really for _,a,b,c in exp do with '_' hidden from the programmer. -- Roberto
That could be useful in cases where one might want to have an iterator return nil for the first visible state variable. For example, imagine wanting an iterator that would deliver just the values from an array over a range -- values( array, lo, hi ) -- this won't work if there is a nil in the array.
I had better examples where I'd wished for this, but the caffeine hasn't kicked in enough this morning for me to remember them.
Mark