[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: New object system in 7 LoC
- From: Leo Razoumov <slonik.az@...>
- Date: Mon, 21 Nov 2011 09:15:14 -0500
On Sun, Nov 20, 2011 at 07:27, Stefan Reich
> 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
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.