Closed mu001999 closed 3 years ago
Currently we can simulate OOP by coding like the following:
@Student(age) {
@this: {};
return this;
};
student: Student(10);
println(student.age);
But it is not convenient to implement other aspects of OOP such as interfaces, inheritances and so on in this way. So it is a PLAN to provide some more convenient ways to support in Anole.
Of course, this is a plan and it may not be applied finally in fact.
Just TRY.
The way to declare a class in Anole is that using symbol @@
long long ago. But this symbol may cause dazzling and although it is a token in currently but not used in fact. So we decide to remove it and others about it such the old new expression above all.
We are considering whether the defined class is an object and whether we could pass it as an argument.
As dict {...}
and enum {...}
, the direct plan is to design declaration of class as class {...}
named class-expression. If we do some declarations like @Student: class {...}
, the Student is still a variable binded to a class-object, so each class-object doesn't have its own name although we can add other rules like class <name> {...}
. The defect of that each class-object is anonymous is unknown yet. Maybe we can consider the variable binded to an anonymous class-object as a alias.
This is considered in PROPOSAL#20
Finally, we PLAN to choose the PROPOSAL#20
PLAN to support OOP in Anole