lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thursday 16 September 2004 01:28, Fabio Mascarenhas wrote:
> Depends on how you interpret the for loop. If you interpret the loop as:

Actually, I'd rather like the loop variable to be made read-only, so that the 
compiler will produce an error or at least a warning if you try and modify a 
loop variable. Given that the current behaviour is undefined it's not a very 
useful thing to want to do anyway... and I can't count the number of times 
I've had obscure bugs due to accidentally modifying a loop variable. Mostly 
due to this:

for _, i in list do
 _, j = somefunction()

On a slightly related note, is there any chance of getting real syntax for 
discarding a return value? The convention above of using _ for unwanted 
arguments is misleading; it's actually creating a variable called _. It took 
a while before I realised this, hence the above code.

Does anyone actually use variables called _ for any real purpose, and if so, 

+- David Given --McQ-+ 
|    | Uglúk u bagronk sha pushdug Internet-glob búbhosh
| ( | skai.
+- --+