[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ 5.4 ] Sequence Iteration - Knowing when to Stop?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 1 Jun 2018 21:30:53 +0200
2018-06-01 17:56 GMT+02:00 Russell Haley <russ.haley@gmail.com>:
> Well I've been at this for three years now and it's still a PIA for me and
> all the people that want to see an array data type. I *hate* having to use
> arrays in JavaScript, but I guess I'll have to throw my hat in that ring.
> NIL_IN_TABLE seems like a pretty minor compromise for allowing predictable
> sequences.
I've been in Lua, coming from Python, but further back from Pascal,
for seven years. The first two of them I spent lamenting the Python
data structures missing from Lua (i.e. lists, arrays and tuples, Lua
seemed to have only dictionaries). At the same time I gradually
mastered the more advanced features of Lua: metatables, generic
`for`, coroutines. Nowadays, I think in Lua.
On the rare occasions that I can't avoid writing Python, I spend half
of my time in the interactive help and the other half cursing the
non-equivalence of the invisible difference between a tab
and four spaces.
There is nothing involving arrays that you can't do with metatables
except write a table literal that will automatically imply a metatable.
Nobody compels you to use the table library. I have a whole file
of specialized tables: deque, stack, queue, list. An array is just
a special case of a deque, where upper and lower bounds are
variable.
But speaking of the table library: I wonder how many people are
using the very powerful 5.3 table.move. And how many people
have noticed the trivial implementation of nil-impervious
table.insert and table.remove that is possible with table.move.