Closed mu001999 closed 3 years ago
This PROPOSAL may make classes could be generated dynamically and as values for passing or returning.
Add NEW Token class
Create a (anonymous) class-object in the following way, and the Bar
is the alias of the anonymous class:
@Bar: class {
...
};
We enable creating a class-object with a name like that mentioned in FEATURE#17 Support OOP, the name will be recorded as one meta-information. For example:
class Bar {
...
};
equals:
@Bar: class Bar {
...
};
The second Bar
is the unique name for the class-object and the first one is an alias. So if we do in the following way, Foo
is an alias of Bar
, but we can't create an object of Bar
with the name self:
@Foo: class Bar {
...
};
That is, we consider all variables as aliases.
For details of the definition of one class, the PLANED design of inheriting is as the following:
@Foo: class(Bar) Baz {
...
};
As the way mentioned, we can consider the keyword class
as a function which receives base classes and then returns a new class-object.
For details of definitions of members of one class, the PLANED design is as the following:
class Student {
data: 0;
instance_method(self, ...) {
....
};
class_method(cls, ...) {
...
};
};
Student.class_method(...) makes the first parameter binded to class Student while Student().instance_method(...) makes the first parameter binded to the instance.
This issue is about a proposal of FEATURE#17 Support OOP which considers class declarations as objects.