lua-users home
lua-l archive

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

Can I make a suggestion for 5.2 that I don't think I've seen here before? (If it has, I apologize; regrettably, I haven't kept up with every message on the list these days.)

When adding a new member to a table, I find myself writing code of the form

  p[ #p + 1 ] = value

a lot. In that case, it's not too awful, but if the table has a meaningful name, it become sort of cumbersome:

  tableWithMeaningfulName[ #tableWithMeaningfulName + 1 ] = value

Whatever you may think of PHP, there is one language feature there that I would be happy to see brought over to Lua: a shorthand for doing this operation

  tableWithMeaningfulName[] = value

In other words, omission of the table index inside the square brackets should be expanded to mean the next available integer index.