[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Lua 5.2] Object Oriented Programming with _ENV
- From: Nilson <nilson.brazil@...>
- Date: Thu, 30 Sep 2010 13:57:43 -0300
On Thu, Sep 30, 2010 at 12:47 PM, Jerome Vuarand
<jerome.vuarand@gmail.com> wrote:
> And with a simple token filter, you could even leave the line out. For
> example with a new "method" keyword :
>
> method Class:Method (bar)
> foo = bar -- assign self.foo = bar
> end
>
If you are using the OOBit, you can also replace the colon with the dot.
method Class.Method (bar)
foo = bar -- assign self.foo = bar
end
or:
Class.Method = method (bar) foo = bar -- assign self.foo = bar end
or even:
Class = {
foo = 10;
Method = method (bar) foo = bar -- assign self.foo = bar end;
}
> would be equivalent to :
>
> function Class:Method (bar)
> local _ENV = wrap(self)
> foo = bar -- assign self.foo = bar
> end
>
>
Just a small advertisement.
--
Nilson