lua-users home
lua-l archive

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

I understand that. Sorry, I think I misread your message. I thought you where commenting on something else.

Now that I think about it, there is a problem with the example but I don't think we agree on where the problem is. Let me explain:

I expect the following statements to throw the same error...

for node in traverse(nil) do ... end
for node in traverse(8008135) do ... end
for node in traverse("string") do ... end

That seems natural to me. The error message could be made friendlier, but I don't see why nil needs to be a special case. The problem, in my opinion, is the following line...

list = nil

For this example, I think that an empty list is better represented by an empty table than a nil. Of course, a non-empty list can still be terminated by a nil or an empty table.


Taj Khattra wrote:
The two statements are equivalent. Re-read section 3.3.

=(function() if not nil then return nil else return 1729 end end)()
=(not nil and nil or 1729)