setmetatable vs. using functions to make class

 Since there is not a built in class function in Lua I figured two work arounds to imitate the function

First is the well known setmetatable function, the other is making my own function

for example

 local enemyTable = {} local function createEnemyClass() local enemy = display.newImage("enemy.png") enemy.x = math.rand() enemy.y = 0 enemy.hp = 1000 function enemy:hitHp(dmg) self.hp = self.hp - dmg end table.insert(enemyTable,enemy) return enemy end 

 The thing Im concerned is will creating instances with the same properties and functions in this method be less effective than using the set metatable function?

 since functions like hitHP will be defined newly every single time an instance is made whereas, ( im not sure but) functions in a table with the same metatable has its functions stored once in a designated location?