[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: inheritence and base element syntax cookie ?
- From: PA <petite.abeille@...>
- Date: Fri, 21 Apr 2006 13:58:52 +0200
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/