Suggestions for improving our constructors? #3286
Unanswered
ipsquiggle
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
In a perfect world, I feel like passing |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, we are using a class system which requires passing in the constructor as a lambda. This plays quite poorly with LuaLS as far as I can tell. I've made it work, sort of sometimes, but am wondering if anyone has suggestions to make this more succinct.
Here's what I've got:
Okay, kind of awkward. Let's talk about what I've got here.
TestClass("b")selfas just a normal parameter. In order to fix this, I have to redeclare the class in this scope (3b) and then provide some variable to the declaration to attach to (3c). This is highly unfortunate.After doing this, the autocomplete on
test_instis.field_constr,.field_meth, and:Bar()as expected. If I leave out 3b/3c, then.field_constris missing (because it was an illegal injection).So my question is: Can anyone suggest any ways to clean up this mess? Ideally, 3a just works all the time, 3b and 3c are not necessary at all, and in a perfect world, 2a is not even necessary. We have tons of legacy code and so can not change the way our class system works, and are trying to find a compromise that gives us the best type information and the fewest warnings.
Edit: cleaned up unhelpful wordings.
Beta Was this translation helpful? Give feedback.
All reactions