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

Could you create one with classes? #40

Open
BlueSilenceLiu opened this issue Aug 3, 2022 · 1 comment
Open

Could you create one with classes? #40

BlueSilenceLiu opened this issue Aug 3, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@BlueSilenceLiu
Copy link

I found out that it is difficult to write a complex program: we need classes.
C++ is actually C with classes, so maybe you can update it and reneme to Z++
I suggest to use this syntax:

class ExampleClass (SuperClass)
{
    func constructor(Param1, Param2, ...)
    {
    // This function is called when the instantiated object is created
    // [some code]
    int this.example_attribute = 10
    super()    // call constructor function of super class
    this.super().ExampleMethod()    // call the static method 'ExampleMethod' of SuperClass
    this.ExampleMethod2()    // This is not defined in ExampleClass, so it will look for this function in SuperClass
    }

    func example_method(Param1, Param2, ...)
    {
    // [some code]
    }

    static int example_static_attr = 15
    // a static attribute/method is the attribute of class
    // e.g.
    // >> ExampleClass ExampleInstantiatedObj = (1, 2, 3)
    // >> printl(ExampleInstantiatedObj.example_static_attr)    => error
    // >> printl(ExampleClass.example_static_attr)                     => 15

    static func example_static_method(Param1, Param2, ...)
    {
    // [some code]
    }
}
ExampleClass a = (1, 2, 3)    // this calls a.contructor(1, 2, 3)
a.example_method()

P.S. This idea is mainly from javascript (constructor right?)
also it should support operator overloading then it looks much better

@BlueSilenceLiu BlueSilenceLiu added the enhancement New feature or request label Aug 3, 2022
@asciidude
Copy link

This would have been nice to see, sucks to see this project come to an end :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants