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

Allow implementing interfaces after type declaration #995

Open
alexnask opened this issue May 10, 2016 · 1 comment
Open

Allow implementing interfaces after type declaration #995

alexnask opened this issue May 10, 2016 · 1 comment

Comments

@alexnask
Copy link
Collaborator

Proposed syntax:

Fooable: interface <T> {
    foo: func -> T
}

// Perhaps 'extend Cell<T> implements Fooable<T>'
extend Cell<T> as Fooable<T> {
    foo: func -> T {
        val
    }
}

@fasterthanlime
Thoughts?

@alexnask
Copy link
Collaborator Author

alexnask commented May 10, 2016

Potential issues:
What happens if the type already implements the interface but hasn't been declared that way?

For example:

Printable: interface {
    toString: func -> String

    print: func {
        toString() println()
    }
}

extend Int as Printable {
    // 'toString: func -> String' already exists in the original Int declaration
    // Should it be automatically detected?
    // Obviously, you cannot re-declare it.
}

Edit: In my opinion, interface required functions not implemented in the addon should be looked up in the type declarations and used automatically.

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