lua-users home
lua-l archive

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




On 25/06/16 08:17 PM, Tim Hill wrote:

On Jun 25, 2016, at 3:15 PM, Philipp Janda <siffiejoe@gmx.net <mailto:siffiejoe@gmx.net>> wrote:

Ignoring syntax and compatibility issues for a moment, what would you have
if a table had an explicit, unambiguous, first-class array length?

— No confusion over the meaning/behavior of ipairs().

What about `ipairs()` is confusing? It's just like with C strings: the first `NUL`/`nil` terminates the thing. Normal Lua tables on the other hand are like Pascal strings that only remember their capacities, not their sizes, so you have to find the (or a) terminating `nil` anyway.

It’s confusing when # does one thing and ipairs() does another. If you recall the debate over changes to ipairs() prior to Lua 5.3 (and the changes it underwent during the betas) than yes, I think it can be called confusing. Remember that as a scripting language Lua often has programmers who have far less software knowledge than a seasoned C/C++ veteran, and so the language really needs to be as consistent as possible (imho).
Next up, we should try to get smart quote support, so users can edit scripts in notepad.exe and the mac/OSX/whatever it's called nowadays text editor without them breaking. /s

And you only have to look at the number of times the whole issue with sequences/#/nil comes up in this mailing list.

—Tim


--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.