Alt Text


i was reading the documentation again yesterday at work and that was such a raw line that i just opened up my work laptop so i could find exactly where it was lmao
having 4 different versions can be a lil confusing to find, but the redundancy is sometimes super nice bc the same content is explained in different ways
also it's fun the see the writing style evolve over time - much more first person and casual in v1
alt text backfill
11 – Data Structures

Tables in Lua are not a data structure; they are the data structure. All structures that other languages offer---arrays, records, lists, queues, sets---are represented with tables in Lua. More to the point, tables implement all these structures efficiently.

In traditional languages, such as C and Pascal, we implement most data structures with arrays and lists (where lists = records + pointers). Although we can implement arrays and lists using Lua tables (and sometimes we do that), tables are more powerful than arrays and lists; many algorithms are simplified to the point of triviality with the use of tables. For instance, you seldom write a search in Lua, because tables offer direct access to any type.

It takes a while to learn how to use tables efficiently. Here, we will show how you can implement typical data structures with tables and will provide some examples of their use. We will start with arrays and lists, not because we need them for the other structures, but because most programmers are already familiar with them. We have already seen the basics of this material in our chapters about the language, but I will repeat it here for completeness.

Programming in Lua (first edition)
Part II. Tables and Objects 
Chapter 11. Data Structures
https://www.lua.org/pil/11.html