|
On Sun, Feb 23, 2014 at 10:11 AM, Thijs SchreijerWhich is exactly why I don't think LOOP is good for beginner; it's
<thijs@thijsschreijer.nl> wrote:
> Lua provides the means to do OO, but that also means that you can do it in many different ways. (have a look at LOOP, which implements a bunch of them)
best to understand one scheme well and use it consistently. Otherwise
it is premature optimization.
My (biased) opinion - has reference to Lua wiki article:
http://www.luafaq.org/#T1.28
With this I totally agree. - that's the essence. It can be confusing,
> Understand the table as being the core of an object
> Understand __index metamethod
because we often set the 'class' table __index to point at the class
table itself. This is convenient, but not necessary; important thing
to understand is that putting methods into a table's metatable does
not automatically make them available.
Not crucial to using OOP in Lua; it's an implementation strategy. I
> Understand difference between 'fat' inheritance (copying all members of a class into a new table), versus 'dynamic' using the __index metamethod (a change to an ancestor might change all descendants)
like 'fat' inheritance because there are no long chains of lookup for
deep class hierarchies, and it's all self-contained.
steve d.