On 3 Nov 2013 12:11, "Aleksandar Kordic" <alexandarkordic@xxxxxxxxx> wrote: > > Hi, > > While testing Closure-based object system [1] approach I have noticed > that creating new set of functions for every new object stops JIT > compiler optimizations because each object has its own function > instances that do share the same code but have different upvalues. > > Do I need to avoid upvalues ? What are the best techniques for > associating data to functions ? > You don't need to avoid upvalues but yes you need to avoid creating closures in performance critical code. Best thing to do is use Lua's : notation and pass the data, and/or use metamethods on ffi types. > > [1] http://lua-users.org/wiki/ObjectOrientationTutorial > > -- > Kind Regards, > Alex >