-- rectangle prototype: rectangle_proto= {species="rectangle"} function rectangle_proto:area() return self.width * self.height end -- rectangle constructor: function new_rectangle(width, height) local rectangle= {width= width, height= height} setmetatable(rectangle, {__index=rectangle_proto}) return rectangle end -- rectangle usage: rectangle= new_rectangle(3,4) print(rectangle:area()) --> 12 print(rectangle.species) --> rectangle -- circle prototype: circle_proto= {species="circle"} function circle_proto:area() return self.radius^2 * math.pi end -- circle constructor: function new_circle(radius) local circle= {radius= radius} setmetatable(circle, {__index=circle_proto}) return circle end circle= new_circle(1) print(circle:area()) --> 3.14 print(circle.species) --> circle