[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and composition
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 1 Mar 2017 08:50:39 +0200
2017-03-01 3:10 GMT+02:00 Soni L. <email@example.com>:
> So, Lua has very limited OOP:
> object:method() --> object.method(object)
> But, there are other forms of OOP which are useful:
> These could be added to Lua as a new syntax sugar, the `:.` syntax:
> I believe Lua would benefit from this. Sure, you can just keep a reference
> to the object in object.system/object.trait, but then you can't dynamically
> add new arbitrary systems/traits:
> object.trait = sometraitimpl
> object.trait:method() -- wait, why are you not modifying my `object`?
> object.system = somesystem
> object.system:method() -- ??? you're supposed to modify `object` D:
> object.system.ref = anotherobject -- brokenpatching at its finest
> And this is why I think it's a good idea.
> This could also support any level of nesting:
> a.b.c:d.e.f.g() --> do local c = a.b.c; c.d.e.f.g(c) end -- note how `a.b.c`
> is only evaluated once
Quick standard questionnaire, marks from 0 to 10, 5=neutral,
1. Clarity of proposal?
2. New idea?
3. Do opportunities for using it arise often?
4. Will it improve clarity of coding?
6. Attractiveness of implementation?
10, 0 (the OP himself claimed to have proposed this before April 2016 ),
8, 10, 5, 2 (prefer the way suggested in ).
Cloud Wu has pointed out the start of the previous thread; my references
also come from there.
That time, only the three of us endorsed the idea. Maybe its time has