lua-users home
lua-l archive

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



On Oct 2, 2013, at 9:57 AM, Sean Conner <sean@conman.org> wrote:

 Is a sequence of 0 elements valid?

 So, what exactly is wrong with:

sum = 0
for i = 1 , #t do
  sum = sum + t[i]
end

 I mean, besides not checking if each element is a number and not NaN (but
then again, you can't check for NaN because NaN ~= NaN and there goes your
entire calculation out the window ... )

In my application it is desirable/necessary for me to check that a table is indeed a sequence before further processing it. Lua does not provide any easy or efficient means of doing so. To me this is a flaw in the language. I believe it is easy to fix, but such discussions are frowned upon in this list, so I will not discuss this further.

Pretty much all the other arguments put forward are of the "well I don't see why you need to do it, so you don't need to do it, so you are wrong" variety, which I regard as flawed logic.

--Tim