You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have seen this in python i think where the private property is recognized by using (__) before the variable or function.
module.__index = module
we already use this often so it makes sense for this to be a official way to hide properties and only make them visible inside the module and hide it from the outside.
im well aware that with the wrong name like __add will also act like a meta method but for that you could reserve those names or just let them be i don't see any problem since most people using modules already aware of metatables and advanced at their job.
Or making static properties like module.new is a static property when __index used it will ignore the static properties and private and only use the normal members.
we could use like @Native@Private or @static or __index for private and @static there are many ways this can be achieved.
Bonus request:
im very greatful for the option to comment out functions and i know it is still a early development thing so i want to suggest to make it like lua annotation since they both are similar and makes great for documenting modules and keeping the clients happy.
function module.setVal(n:number): number
privateVal = n
end
function module.getVal(): number
return privateVal
end
return module -- this is not Object orientated programming so for this case the current luau is sufficient.
look at it in an oop style then you will see many problems real quick like making a whole new table for public methods and static now another one for private and so on.
I have seen this in python i think where the private property is recognized by using (__) before the variable or function.
module.__index = module
we already use this often so it makes sense for this to be a official way to hide properties and only make them visible inside the module and hide it from the outside.
im well aware that with the wrong name like __add will also act like a meta method but for that you could reserve those names or just let them be i don't see any problem since most people using modules already aware of metatables and advanced at their job.
Or making static properties like module.new is a static property when __index used it will ignore the static properties and private and only use the normal members.
we could use like @Native @Private or @static or __index for private and @static there are many ways this can be achieved.
Bonus request:
im very greatful for the option to comment out functions and i know it is still a early development thing so i want to suggest to make it like lua annotation since they both are similar and makes great for documenting modules and keeping the clients happy.
link: #https://keplerproject.github.io/luadoc/manual.html
another link: #https://github.com/LuaLS/lua-language-server/wiki/Annotations
The text was updated successfully, but these errors were encountered: