[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Cratera Compiler v1.0.0
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Fri, 2 Aug 2019 11:07:34 -0300
On 2019-08-02 2:47 a.m., Egor Skriptunoff wrote:
On Fri, Aug 2, 2019 at 12:19 AM Soni "They/Them" L. wrote:
> On 2019-08-01 6:05 p.m., Egor Skriptunoff wrote:
>> Could you provide an example to show benefits of traits?
>> What kinds of tasks traits solve better than conventional
>> 'objects-and-methods' approach?
> I recommend reading
(Well, besides reading that, I recommend actually checking out
using it for a while. You'll see what I mean.)
Could you just show a simple example from real-life programming where
using traits is better than not using them?
Such example should be understandable by any Lua programmer (without
If you can't provide such example then why Lua users might want to use
Let's say you have a trait Foo, with perhaps some methods (or all
methods) depending on the object also being a Bar.
With inheritance, your Foo would be a Bar, probably, which makes it an
Take a look at e.g.
Additionally, names don't matter. You can have both Foo and Bar have a
reverse method and it works fine. (this is also the case in Rust)