#dumb question, solved myself.

23 messages · Page 1 of 1 (latest)

bronze steppe
#

dumb question, solved myself.

indigo crane
#

bruh can you tell us what the question was and your solution

#

so others can learn

bronze steppe
#

here i'll rewrite it:

i was wondering why oop was usually done with metatables, rather than just cloning a table, since metatables are generally slower.

i realized that the reason was because cloning the tables would create multiple of the same exact same function, taking up more memory. aswell as the performance boost this being very very very insignificant. (assuming you're not creating more than 1 of the object, after that it would take up more memory anyway)

indigo crane
#

can you explain

#

this seems really interesting

bronze steppe
indigo crane
bronze steppe
#

i'll just give you the basics rq

#

metatables are essientally just fancy tables

#

they're created with

setmetatable(tbl, metatable)
#

a metatable is just another table with 'metamethods'

#

metamethods are used for custom functionality

#

there's metamethods for things like addition, converting to a string, etc

fierce valve
#

since lua isnt oop, metatables are used to mimic it

#

without a metatable, it would work the same but it wouldnt be similar enough to oop to be considered oop

#

if that makes sense