|
Hi callin, (안녕하세요)Thank you for providing me and people good information.Does it have similar feature like C++ virtual member function?For example, YACI(Yet Another Class Implementation)[1] implements similar feature.Thank you very much!SincerelyJourneyer----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l d o t c o m
----------------------------------------2014-02-26 9:36 GMT+09:00 임창진(callin) <callin2@gmail.com>:Hi Joh!if you don't mind I suggest you this one. http://lua-coat.luaforge.net/I use it several project with corona sdk.It has many features but syntax is simple.bad thing is lack of documentation but you can find examples in github test directory.2014-02-25 21:45 GMT+09:00 steve donovan <steve.j.donovan@gmail.com>:
On Tue, Feb 25, 2014 at 5:21 AM, Journeyer J. JohAs Andrew says, the concept does not apply to Lua.
<oosaprogrammer@gmail.com> wrote:
> Does penligh's class library support virtual function?
It is useful to look at the basics of 'OOP' in Lua:
obj:method(args) is exactly equivalent to obj.method(obj,args) - so
'method lookup' is exactly the same as table lookup. So the simplest
possible scheme is to put the functions inside obj, which is wasteful
for many objects - they all have to contain references to the
functions. If obj has a metatable M, and M.__index = T, then if
looking up 'method' fails in obj, it will look in T. This allows us
to keep only the state in the object, and the functions elsewhere.
Easiest way of seeing inheritance is the 'fat metable', where T will
initially contain all the inherited functions ('copy of base class'),
and then the new 'overrides' will be copied into T. To a first
approximation you can think of T as a VMT (Virtual Method Table)
except it is indexed by name, not slot.
So everything is 'virtual', because obj.method will always pick up the
version redefined for that 'class'.
--
임창진(rim.chang.jin)