[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Shorthand for appending to a table (was Re: 5.2 feature list?)
- From: Eric Scouten <scouten@...>
- Date: Mon, 11 Sep 2006 10:40:18 -0700
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.
-Eric