2 ms·
Wait, does that mean that iterating across the members of a Lua table is not in deterministic order? I assume it just uses the naive hash ordering for iterator
by Pxtl 13y ago
Wait, does that mean that iterating across the members of a Lua table is not in deterministic order? I assume it just uses the naive hash ordering for iterators... this is relevant because Lua is used as a scripting-engine SpringRTS which uses a lock-step-based multiplayer approach so anything non-deterministic risks breaking sync.
- finnw 13y ago> Wait, does that mean that iterating across the members of a Lua table is not in deterministic order? Yes. And it is documented as such. Any dependency on repeatable iteration order is a bug.
- Pxtl 13y agoHuh. I'm not involved directly in SpringRTS, but I'm going to take a look at the code... I assume there's a compilation flag for Lua to disable that, or they've hacked it up and are using a custom interpreter, because protecting sync is paramount.
- avar 13y agoJust using "sort(hash-keys())" instead of "hash-keys()" should be a trivial patch that fixes this.