lua-users home
lua-l archive

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

On 06/07/13 17:02, Rena wrote:
dding nil doesn't change anything here: your loop would also break if some confused person stuck a table or a coroutine into the array. It's already necessary to either check that each value is the type you expect or ensure that unexpected types don't end up in the array to begin with, whether nil is an accepted type or not.
I think this is a fundamental difference. Array based algorithms (say binary search, some sorting, or simple traversing) assume that each slot in the array contains something worth looking up, whatever makes sense for the application. Nil is never that, because there is nothing you can do with it. Nil is not something that must have a meaning in the application domain, it's effectively out of band application wise.