4 ms·
Since this is a Lua thread, your reference list should probably start at 1 rather than 0
by aeternum 5y ago
Since this is a Lua thread, your reference list should probably start at 1 rather than 0
- afiori 5y agoIt is about embedding how easy it is to embed lua, so you should be able to use the host conventions
- anothernewdude 5y agoOh wow, that does make the non-standard array references rather catastrophic.
- afiori 5y agoyou wrap the host across the embedding boundary so that the host and lua can either use their own convention or have access to a special object that explicitely and clearly exposes the other convention. In general using array indexes as foreign keys should always be considered carefully. And if all you will be doing is iterating then the starting index doesn't really matter (unless you copy paste loop logic, which is a problem in itself)
- afiori 5y agoErrata: you wrap the host across -> you wrap the array across
- BulgarianIdiot 5y agoBecause of this I always thought lists should be iterable/traversable, but have no direct (numeric) index to their items.
- stirfish 5y agoLike a stream?
- Case81 5y agothink Set in Java does this EDIT: Other than the obvious
- BulgarianIdiot 5y agoYes, like a stream, or an iterator. Where you fetch also a reverse iterator if you wish, filter by some predicate etc. A lot of overlap with both relational algebra/sql and with functional programming filter/map/reduce, I guess. Indexes seem convenient, but they're a hack in most cases. Consider what happens when you sort your array, or delete or insert an item in the middle, or start. Now all your indexes have changed. React had this issue, and this is why they had to add stable "key" to collections so that when you mutate a sequence of <li/> items for example, it doesn't get confused which is which.