lua-users home
lua-l archive

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


Practical problem - description of complicated data, for example complicated game data structures with templates/presets on any level of structure (not only the 1st one). I actually started implementing this class realization after encountering a real data description problem with traditional 'classes/objects'.

As for 'vanilla lua inheritance' - it's just not enough since even an empty table in root of object is not a nil and won't be __indexed. So, any table created simply overloads/ignores all information contained in corresponding parents fields on levels more than 1. I hope I speak clearly enough - I am not quite familiar with all those OOP terms.

Thanks for links though, I'll check them.

On 12/6/06, Fabien <fleutot+lua@gmail.com> wrote:

On 12/6/06, Ivan Smirnov <i.s.smirnov@gmail.com> wrote:
Hello everyone, I've come up to the problem of 'true' inheritance realization in Lua recently. Being correctly implemented, this can give you a full control over data inheritance and storage.

I see the mechanism you want to implement, but I cannot think of the practical problem(s) which it solves. Could you provide a concrete, real life design issue, which is solved in a smarter way by your framework?

Besides, beware that subtyping in records is a very tricky issue, easily leading to unsound programs:  

  http://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)

You might also be interested into looking at Scala, which gives users a fine control on subtyping: http://scala.epfl.ch . It illustrates how tricky class variance is, when you want to do it soundly.



--
Regards,
Ivan Smirnov

Department of Math and Stat Sciences
622 CAB
University of Alberta
Edmonton, AB, Canada
T6G 2G1

ismirnov@math.ualberta.ca, i.s.smirnov@gmail.com