qupa-project / uniview-lang

View once immutability enabling the safeties of immutable code, while enjoying near procedural performance
https://uniview.qupa.org
MIT License
2 stars 0 forks source link

Feature: Classes #34

Closed AjaniBilby closed 3 years ago

AjaniBilby commented 3 years ago

Tie function implementation to a type name

Example

class Person {
  id: int;
  age: int;

  fn Age(p: @Person) {
    p.age = p.age + 1;
    return;
  }

  fn Say(p: Person) {
    print("Person { id: ");
    print(id);
    print(", age: ")
    print(age);
    println(" }");

    return;
  }
}

int main () {
  let p = Blank#[Person]();
  Person.Say(p);
  Person.Age(@p);
  Person.Say(p);
}