typeof(if type(class) == "string" then nil else class)
doesn’t work for some reason
My apologies, the thing I was talking about had been brought down before.
archived comment
Just noticed in the code that you used the functions “getfenv” and “setfenv” which is deprecated and disables a Luau optimization.
I would recommend that you pass the this
object to the first argument of constructor and the new
function constructor should get the class name from the first passed argument. Only problem is that you will need to cache created class constructors (I know you are already doing that on the global environment.) or just ditch the class "Clazz" {}
in exchange of local Clazz = class {}
and add the new
function on created class constructor
Luau does optimize native code generation with types are applied, as it is like saying “This function should be correct, and will not face deoptimization (most likely)”. setfenv
has a negative impact on the performance, but it’s because it disables optimizations across the board (safeenv).
Basically, functions will not face deoptimization when correctly called, and types allow you to get the optimization from the start, why do you think bytecode now includes type information?
You can try through the usage of generics
Wow, Awesome module, dude! char