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
e:[inventory].size()
with
e[inventory]:size()
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 https://en.wikipedia.org/wiki/Entity_component_system