lua-users home
lua-l archive

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


On 4/21/06, Grellier, Thierry <t-grellier@ti.com> wrote:
> function D:m()
>
>   C.m( self )    -- no better OO-like syntax available ? like :C:m() for
> example ?
>
>   print("D:m()") -– I'd like to clearly express this is different from call
> to external function
>

Perhaps this is simple wording issue...

Assuming a class 'List' extending 'Object':

-- define the class
local super = Object
local self = super()
	
-- method for initialization
function self:init( aContent, aMode )
    self = super.init( self )
 	
    -- do subclass stuff
	
    return self
end

'self' and 'super' are sufficiently OO for any practical purpose.
Additionally, 'super' is properly scoped as well.

http://dev.alt.textdrive.com/browser/lu/LUList.lua#L23
http://dev.alt.textdrive.com/browser/lu/LUObject.lua#L57

--
Cheers

--
PA
http://alt.textdrive.com/