[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Changes to table length
- From: ThePhD <jm3689@...>
- Date: Sat, 20 Aug 2016 20:53:56 -0400
I'm going to chime in because my thread was mentioned...
Yes, I started "C API - lua_next traversel of 'array' table" because it was pertinent to my users. People were serializing `std::vector` into tables and make that request that I supposed deserialization as well, but I didn't support deserializing a table into a `std::vector` precisely because I did not know the proper way to iterate the array. In previous issues before I asked, I told people not to rely on iteration order and that it would be dangerous. Still, I think having that thread was useful because it did a few things that I did not see digging into the archives previously:
1) established that Lua 5.3's `lua_geti` (and if you didn't need metatable access, Lua 5.2 and belows `lua_rawgeti`) were exceptionally performant (with actual numeric data and graphs) for dealing with iterating through what is called a sequence (typically an array in other languages)
2) addressed some clever ways to store the length without generating a pathological table case in many implementations and without having to override the #t operation (e.g., storing it in 0. I chose to store it in -1 simply because right now I support Lua tables that have iterations that start with 0, simply because that's the way some other libraries write their 'arrays' and I wanted to be flexible with that).
3) produced some insight for how to treat nil and what to expect from a sequence and the length operator
Yes, some of this addressed in the manual, but parts of it were not and as I understand it, this mailing list is for guidance. Therefore, before making the wrong choice permanently and shipping, I sought out proper guidance. While the conversation does linger on (and I still have a few unanswered questions about the history of Table and how I might manage pointers that get turned into `nil` in an array of pointers from C++), I don't think it's a bad or wasteful thread at all.
But that is just my opinion.