antimony-lang/antimony

Structs

garritfra opened this issue · 0 comments

Implement a simple struct syntax.

struct User {
    username: string,
    first_name: string,
    last_name: string
}

fn main() {
    let user = new User {
        username: "foobar",
        first_name: "Foo",
        last_name: "Bar"
    }

    println(user.first_name)
}

Methods are not relevant yet, as there would already be a hacky way to use this construct:

fn user_full_name(user: User): string {
    return user.first_name + user.last_name
}

fn main() {
    let user = new User {
        username: "foobar",
        first_name: "Foo",
        last_name: "Bar"
    }

    println(user_full_name(user))
}

But they will be added in the future.