so in my game i use a ton of module scripts, which are full of functions that get called approximately ~ 20 times a second. If using a colon, it automatically passes the keyword self to the function. Although in 99.99% of cases this seems like the smart thing to do, does doing it cause excess memory to be transferred, leading to an extra delay when calling the function?
function module:Test(...) -- [uses colon]
print(self) -- self here returns module, which is redundant in most cases
function module.Test(...) -- [uses dot] doesn't pass self; is this faster?
print(self) -- prints nil since the thing that called it was not passed
is it worth using the dot (.) operator to write functions if self is not used at all in the function? is it worth changing functions from colon to dot if self is not used?
As far as I know, there is no difference in speed between using the colon vs. the dot operator. However, using the colon signifies it’s a method of a class because of how self is implicitly passed. If what your writing is not a method and self is not needed, it would be smarter to use the dot operator. It’s basically syntactic sugar.
Using : is usually reserved for OOP but there is zero difference in efficiency. If you use self (except when intentionally defined in the module or function itself), good chance that : may be useful over .