3 ms·
Lua's tables seem like a pretty elegant solution to the dynamic-array-like datastructure, and they're also usable as a relational map. Also, Lua is not object-o
by silentbicycle 18y ago
Lua's tables seem like a pretty elegant solution to the dynamic-array-like datastructure, and they're also usable as a relational map. Also, Lua is not object-oriented, but it's trivial to build on the core semantics to make it OO, when doing so would be a practical approach to the problem at hand. (As far as the iteration concern, everything in Lua besides unboxed primitives is a (pseudo-hash) table.)
> But I don't know how to make iteration on any of these look equivalent without making the core of the language be more object oriented.
Haskell's typeclasses would work, as well, and in practice seem to generalize far better. Instead of restricting the iterator used to a specific type, restrict it to any type that supports the interface of iteration. (It's kind of like duck-typing that is verified at compile-time.) It sounds like Clojure has a similar mechanism.