News for hackers. Stuff that matters.
Re:Show HN: MicroLua – Lua for the RP2040 Microcontroller by bxparks on Saturday November 04, 2023 @02:03AM (#38138587)
Does Lua have primitive arrays now? When I looked at it some years ago, it seemed to support only hash maps, and arrays were emulated using hash maps, which I found to be completely bizarre. There were discussions online where Lua folks were saying, no, you don't really need arrays. And I'm thinking to myself, hell yeah, I really needs arrays on resource-constrained microcontroller systems without garage collection.
Re:Show HN: MicroLua – Lua for the RP2040 Microcontroller by vore on Saturday November 04, 2023 @02:09AM (#38138613)
If a table is contiguously indexed by integers from 1, the storage is optimized into an array.
Re:Show HN: MicroLua – Lua for the RP2040 Microcontroller by ckolkey on Saturday November 04, 2023 @03:25AM (#38138894)
Yeah, tables serve as both lists and maps. You can even have a table with _both_.
Re:Show HN: MicroLua – Lua for the RP2040 Microcontroller by debugnik on Saturday November 04, 2023 @08:52AM (#38140597)
That discussion must have been really long ago, otherwise you missed the point. Since Lua 5.0 (2003) tables are implemented as a pair of an array and a hashmap, and the array part can even handle small nil gaps. So tables used as arrays are implemented as arrays as well.