Skip to content

Could you create one with classes? #40

Open
@BlueSilenceLiu

Description

@BlueSilenceLiu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions