On Fri, Aug 2, 2019 at 12:14 AM Soni "They/Them" L. wrote:
Inventory may not be self-contained. Inventory could reference another
trait.
AFAIU "trait" in Rust is the same as "interface" in other languages.
You must implement interface for a class to be able to use it with objects of this class.
In other words, a trait have to be "rooted" into a class.
That's why I don't understand what do you mean in "Inventory may not be self-contained".
Please give a non-trivial example about "a trait could reference another trait" (in Cratera, not in Rust).
My intention was to understand whether the Cratera-like syntax "a:b.c(x)" would bring additional expressiveness to Lua or not (I hope it would, and I guess you can show an example).
But there are 10 replies posted already in this thread, and I still can't imagine a real-life use case where traits could lead to a better code (more readable/compact/etc).
Is traits really just a Rust-nostalgic feature (as you've said: "It's just a different way of doing OOP"), which actually doesn't add new power to Lua?