classes

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

classes

fschmidt
Administrator
I don't really like the way Lua implements classes.  The difference between ":" and "." is confusing and the use of advanced features like setmetatable and __index don't seem necessary.  Here is how I would implement the examples in the "Programming in Lua" book:

oo.lua

Note that this works fine in Lua as it is.  If you think this is good enough, then I won't implement the ":" operator.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: classes

Hugo <Nabble>
Sounds good to me. This is another example of a feature that can be improved later without harming previous code. Also, I am still not sure how much Nabble will rely on classes, so I think we can keep it simple for now. But what about metamethods like __index, __add, __div, etc.? Do you plan to skip them too?
Reply | Threaded
Open this post in threaded view
|

Re: classes

fschmidt
Administrator
I am implementing metamethods now.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: classes

Hugo <Nabble>
Okay, back to you.
Reply | Threaded
Open this post in threaded view
|

Re: classes

fschmidt
Administrator
closing thread
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture