Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROPOSAL] A Proposal of OOP Support #20

Closed
mu001999 opened this issue Sep 24, 2020 · 5 comments · Fixed by #23
Closed

[PROPOSAL] A Proposal of OOP Support #20

mu001999 opened this issue Sep 24, 2020 · 5 comments · Fixed by #23
Labels

Comments

@mu001999
Copy link
Collaborator

mu001999 commented Sep 24, 2020

This issue is about a proposal of FEATURE#17 Support OOP which considers class declarations as objects.

@mu001999
Copy link
Collaborator Author

This PROPOSAL may make classes could be generated dynamically and as values for passing or returning.

@mu001999
Copy link
Collaborator Author

mu001999 commented Oct 1, 2020

Add NEW Token class

@mu001999
Copy link
Collaborator Author

mu001999 commented Oct 1, 2020

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.

@mu001999
Copy link
Collaborator Author

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.

@mu001999
Copy link
Collaborator Author

mu001999 commented Oct 14, 2020

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.

@mu001999 mu001999 mentioned this issue Oct 17, 2020
@mu001999 mu001999 linked a pull request Oct 17, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant