Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primary constructor #612

Open
dzikoysk opened this issue Jan 19, 2021 · 0 comments
Open

Primary constructor #612

dzikoysk opened this issue Jan 19, 2021 · 0 comments

Comments

@dzikoysk
Copy link
Member

dzikoysk commented Jan 19, 2021

Current candidate: v3

module lang

/*
 * PROPOSALS
 */

/* v1 */
open type Foo {

    shared String name
    shared Int value
    internal nil Bar optional

    init (String name, Int value) {
        this.name = name
        this.value = value
    }

    init (String name, Int value, Bar optional) {
        this(name, value)
        this.optional = optional
    }

}

/* v2 */
open type Foo (

    shared String name
    shared Int value

) {

    internal nil Bar optional

    init (String name, Int value, Bar optional) {
        this(name, value)
        this.optional = optional
    }

}

/* v3 */
open type Foo {

    shared String name
    shared Int value

    ~ internal State state1
    ~ internal mut State mutableState2 = State()

    init (base) {
        this.mutableState1 = State(name, value)
    }

}

/* v4 */
open type Foo {

    shared base String name
    shared base Int value

    internal State state1
    internal mut State mutableState2 = State()

    init (base) {
        this.mutableState1 = State(name, value)
    }

}

/* v5 */
open type Foo {

    shared String name
    shared Int value

    internal ext State state1
    internal mut ext State mutableState2 = State()

    init (base) {
        this.mutableState1 = State(name, value)
    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant