Gregofi / camel

Custom dynamic programming language
MIT License
6 stars 1 forks source link

Draft: OOP - Classes #45

Closed Gregofi closed 1 year ago

Gregofi commented 1 year ago

Add classes to the language.

class Person {
   def Person(...) = <constructor-body>;
   def foo() = ...;
};

No static methods.

Operator overloading as defining methods which can have various names:

class List {
    def List() = {
        val data = Nil;
    }
    def appended(other) = <new linked list>;
    def ::(other) = appended(other);
}

Further analysis should be done if it is even possible (if the grammar allows it).

Lets try to avoid this keyword, first lookup methods in class, then elsewhere. No inheritance. Inheritance is good for polymorphism, otherwise composition will suffice.