lua-users home
lua-l archive

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


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