New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] OOP Structures, Syntactic Sugar #48
Comments
There's already a patch introduced for this type of function declaration, so this is likely something I can implement with minimal headache (but I could be wrong). As for properties, I will need to review the parser, but I imagine it can be done, but this may be redundant too since it plays no effect in the behavior of the table (you still create them with the create function). Not so sure about the struct keyword, appears redundant. After all, it's not a structure, it's just a table. And if I did implement it, it would just be skipped by the parser. So you could imagine. But otherwise, suggestion seems nice. I'll keep ya posted. |
I was already working on an implementation on my fork, what is the function declaration you are talking about? |
http://lua-users.org/wiki/LuaPowerPatches Edit, link is down. Searched through the web server manually and got the file: |
The reason why I am making a new keyword is because the functionality it intends to abstract over is not just a table/function, it's also the setmetatable function calls, and the indexing. It would be ambiguous as just a table |
Why would setmetatable be needed? And why would indexing need to change too? |
It is the idomatic way of doing this paradigm. I also want to add a "private" attribute that is only valid in the struct declaration which would make it only available to methods in the struct. This would not make any sense outside of the struct declaration, and even in a regular table |
That's about inheritance, which is fairly unrelated. Users can do this manually in their |
Progress update, |
Thank goodness, the lua parser was killing me |
Yep! I have been folliwng this project closely, looks great |
Currently in lua, there is quite a bit of boilerplate code for creating "structs" or "classes" for OOP, and the way it is done is hard to get done "properly" and soundly
Having this abstracted away would offer usability and readability improvements.
(Some syntax I thought up):
The text was updated successfully, but these errors were encountered: