-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
OOPObject Oriented ProgrammingObject Oriented ProgrammingenhancementNew feature or requestNew feature or requestproposalRadon Enhancement Proposal (REP)Radon Enhancement Proposal (REP)syntaxLanguage SyntaxLanguage Syntax
Milestone
Description
We are making Radon a true object oriented language like Python. We are willing to add almost all natures a OOP language supports.
-
classkeyword support. -
BuiltInClassfunctionality to add built in classes like we haveBuiltInFunctions. We have mentioned this on Need BuiltInClass or Object for defining internal classes. #23 -
BuiltInInstanceto handle classes objective behaviours. - Operators overloading systems to handle classes operational behaviours.
A basic sudo implementation of OOP in Radon will be like this.
class MyClass {
fun __constructor__(this, any, others, args=null) {
this.any = any
this.others = 16*others
}
fun __add__(this, other) {
return MyClass(
this.any + other.any,
this.others + other.others,
this.args + other.args
)
}
fun __destructor__(this) {
pass
}
}
- At the place of
__add__we can set__sub__,__mul__,__div__,__len__etc. more will be added as we move forward. - We will use
len(object)to get length from a class which will be come from__len__. And will support more methods so on... #120 - Our current constructor is the class name, but want to set it to
__constructor__. - We will add a
__destructor__method to delete the object. #93 - Our current function declaration keyword is
funand it will be fixed untill any second thoughts arrives. Methods will be same like functions. -
passkeyword support. #88 -
...orEllipsissupport. #89 -
delto delete objects. #92 -
statickeyword support for static methods.
Realistic OOP behaviors.
- Abstraction support.
-
abstractkeyword support.
abstract class AbstractClass() {
fun some_method1(args1, args2, ...) # No implementations
fun some_method2(args1, args2, ...) # No implementations
}
class NewClass(AbstractClass) {
fun some_method1(args1, args2, ...) # Have to complete anyway
{
# implementations
}
fun some_method2(args1, args2, ...) # Have to complete anyway
{
# implementations
}
}
- Encapsulation support.
-
public,private,protectedkeyword support.
class ExampleClass {
fun __constructor__(something) {
this.something = something
}
# All methods by default public. explicitly definitions allowed.
fun some_method() {
return 123
}
public fun public_method() -> 0
private fun private_method() {
return 123
}
protected fun protected_method() {
return 123
}
}
- Polymorphism support.
Operator overloading is a part of polymorphism, which is already done.
If anything missing, will be updated later. - Inheritance support.
- Single Inheritance.
- Multiple Inheritance.
- Multilevel Inheritance.
- Hierarchical Inheritance.
- Hybrid Inheritance.
class ParentClass {
fun __constructor__(something) {
this.something = something
}
fun some_method() {
return 123
}
}
class ChildClass(ParentClass) {
fun __constructor__(something_new) {
this.something_new = something_new
super().__constructor__(something)
}
}
child = ChildClass()
child.some_method() # will work!
We will update this issue as we change our plans.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
OOPObject Oriented ProgrammingObject Oriented ProgrammingenhancementNew feature or requestNew feature or requestproposalRadon Enhancement Proposal (REP)Radon Enhancement Proposal (REP)syntaxLanguage SyntaxLanguage Syntax