lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 2019-08-01 6:13 p.m., Soni "They/Them" L. wrote:

On 2019-08-01 6:05 p.m., Egor Skriptunoff wrote:
On Thu, Aug 1, 2019 at 4:53 PM Soni "They/Them" L. wrote:

    -- example from tests.cratera

From your example it's not clear why this feature is better than usual OOP syntax. Actually you DO NOT need reference to 'e' inside trait's functions (get, set, size).
You can easily rewrite your program in traditional way by replacing

Could you provide an example to show benefits of traits?
What kinds of tasks traits solve better than conventional 'objects-and-methods' approach?

Inventory may not be self-contained. Inventory could reference another trait.

I recommend reading

(Well, besides reading that, I recommend actually checking out Rust and using it for a while. You'll see what I mean.)