lua-users home
lua-l archive

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

On this day of 01/14/2008 06:03 PM, Javier Guerra Giraldez saw fit to
> On Monday 14 January 2008, Eric Tetz wrote:
>> On Jan 14, 2008 2:39 PM, Jerome Vuarand <> wrote:
>>> Just use the simplest one until you feel you need more features.
>> But if Jane writes class X using one model, Joe can't derive class Y
>> from it using a different model, right? So this does nothing to
>> ameliorate the problem I was talking about. Doing any OO programming
>> in Lua represents a commitment to a specific scheme, or the acceptance
>> that you will have N incompatible object representations in your code.
> great, this is a specific problem (or perceived problem); so let's analyse it 
> specifically :-)
> first my favourite point: inheritance is _very_ seldom the best answer.
> why is inheritance so common? i believe it's because static-typed languages 
> need some assurance about 'minimum commonality' between two similar objects.  
> (...)
> in fully dynamic languages, where there's no compile-time type checking, 
> there's no need to assure any pre-set commonality structure between similar 
> objects.  (...)
> in short: inheritance is on most cases not a feature, just a simplistic method 
> for expressing similarity.

I think this is a good point. In a dynamic language sub-typing is
probably more common than inheritance; and sub-typing happens naturally
in a dynamic language when you share method names. On the (perhaps
infrequent) cases where you need actual implementation inheritance, you
can do it by adopting some appropriate policy.

- David