Rect = { x = 0, y = 0, width = 10, height = 20, } function Rect:area() return self.width * self.height end function Rect:new() o = {} o.x = self.x; o.y = self.y; o.width = self.width; o.height = self.height; o.area = self.area; return o end ex1 = "print(Rect:area()); r2 = Rect:new(); r2.width = 1 ; print(r2:area()); print(Rect:area())" f = loadstring(ex1) f()