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
localAnimal=Extends(Object)
functionAnimal:Speak(self)
print('Animal.Speak')
endlocalPerson=Extends(Animal)
functionPerson:Speak(self) --- No error and diagnostics message print('Person.Speak')
endlocalp1=New(Person)
p1:Speak() -- Code completion matches the function `Person:Speak(self)`
Actual Behaviour
localAnimal=Extends(Object)
functionAnimal:Speak(self)
print('Animal.Speak')
endlocalPerson=Extends(Animal)
functionPerson:Speak(self) --- Err: Duplicate field `Speak`. Lua Diagnosticsprint('Person.Speak')
end
Reproduction steps
Just copy the code and let lsp lint them
Additional Notes
My Points:
Polymorphism is a Core Feature of Object-Oriented Programming:
Polymorphism is one of the core features of object-oriented programming. It allows different objects to use the same interface but exhibit different behaviors. It is widely used in many programming languages and is a key method for writing maintainable and extensible code.
Lua is a Dynamic Language:
Lua is dynamically typed, meaning it does not need to determine types at compile time like static languages. This provides great flexibility for programming. Through metatables and mechanisms such as __index and __call, Lua can implement many traditional object-oriented features, like inheritance and polymorphism.
If Polymorphism is Opposed, Static Languages Should Be Chosen Instead of Using duplicate-set-field:
If dynamic polymorphism is not acceptable, instead of enforcing the duplicate-set-field rule, a feature like @Final annotation should be introduced. Until such a feature is implemented, no changes should be made.
If dynamic polymorphism is unacceptable, instead of adding duplicate-set-field, developers should consider other programming languages such as C#, Java, or C++, which are statically bound and support the final syntax for methods.
Performance Trade-offs in Scripting Languages:
The design of scripting languages typically makes trade-offs between performance and flexibility. For example, Python's OOP is based on the dict mechanism, which allows dynamic modification of object behavior. Ruby, on the other hand, uses the Object, BasicObject, Class, and ancestor lookup chains to achieve flexibility, which sacrifices some performance.
For most scripting languages, performance is not the sole design consideration. Development efficiency, maintainability, and extensibility are the key goals. Over-optimization for performance, especially by limiting flexibility, is contrary to the design intent of scripting languages.
Log File
No response
The text was updated successfully, but these errors were encountered:
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
Actual Behaviour
Reproduction steps
Additional Notes
My Points:
Polymorphism is a Core Feature of Object-Oriented Programming:
Polymorphism is one of the core features of object-oriented programming. It allows different objects to use the same interface but exhibit different behaviors. It is widely used in many programming languages and is a key method for writing maintainable and extensible code.
Lua is a Dynamic Language:
Lua is dynamically typed, meaning it does not need to determine types at compile time like static languages. This provides great flexibility for programming. Through metatables and mechanisms such as __index and __call, Lua can implement many traditional object-oriented features, like inheritance and polymorphism.
If Polymorphism is Opposed, Static Languages Should Be Chosen Instead of Using duplicate-set-field:
If dynamic polymorphism is not acceptable, instead of enforcing the duplicate-set-field rule, a feature like @Final annotation should be introduced. Until such a feature is implemented, no changes should be made.
If dynamic polymorphism is unacceptable, instead of adding duplicate-set-field, developers should consider other programming languages such as C#, Java, or C++, which are statically bound and support the final syntax for methods.
Performance Trade-offs in Scripting Languages:
The design of scripting languages typically makes trade-offs between performance and flexibility. For example, Python's OOP is based on the dict mechanism, which allows dynamic modification of object behavior. Ruby, on the other hand, uses the Object, BasicObject, Class, and ancestor lookup chains to achieve flexibility, which sacrifices some performance.
For most scripting languages, performance is not the sole design consideration. Development efficiency, maintainability, and extensibility are the key goals. Over-optimization for performance, especially by limiting flexibility, is contrary to the design intent of scripting languages.
Log File
No response
The text was updated successfully, but these errors were encountered: