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

Structures #14

Closed AjaniBilby closed 3 years ago

AjaniBilby commented 3 years ago
AjaniBilby commented 3 years ago

Test Case 1

struct Person {
    int id;
    int age;
    float height;
}

Person init() {
    Person p = Blank#[Person]();
    decompose p;
    p.id = 0;
    p.age = 18;
    compose p;

    return p;
}

int main() {
    Person p = init();
    print(p.age);

    return 0;
}
AjaniBilby commented 3 years ago

Test Case 2

struct Person {
    int id;
    int age;
    float height;
}

Person init(bool ofAge) {
    Person p = Blank#[Person]();
    p.id = 0;
    if (ofAge) {
        p.age = 21;
    } else {
        p.age = 16;
    }

    return p;
}

FAILED

AjaniBilby commented 3 years ago

Now successfully passes both test cases

AjaniBilby commented 3 years ago

Requirements Before Merging

Able to decompose by automatically

Person p = Blank#[Person]();
p.age = 18;

Able to handle multiple composition states

Person p = Blank#[Person]();
if (ofAge) {
    p.age = 21;
}
consume(p);
AjaniBilby commented 3 years ago

Progress Summary:

AjaniBilby commented 3 years ago

Progress Summary: