lua-users home
lua-l archive

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

On Sun, Nov 20, 2011 at 07:27, Stefan Reich
<> wrote:
> Hi guys!
> I just created a neat little object system for Lua (5.1) that does pretty
> much exactly what I want.
> You use it like this:
> newThing = object(function() -- could add arguments here too
>   var1 = 1
>   local var2 = 'test'
>   function method1()
>     var1 = var1+1
>   end
> [[snip]]

An elegant idea, indeed! And  'self' reference is avoided.

There is one problem, though.
Every time you create a new object instance brand new closures for all
your instance methods are created as well. In case you have many small
objects it can cost you memory and also CPU.