Skip to content

Support abstract operators #796

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

Closed
davidhesselbom opened this issue Aug 18, 2014 · 0 comments
Closed

Support abstract operators #796

davidhesselbom opened this issue Aug 18, 2014 · 0 comments
Milestone

Comments

@davidhesselbom
Copy link
Contributor

It should be possible to make abstract operators and use them in methods in abstract classes. Example (does not currently build):

Matrix: abstract class {
// I don't know if it should be "abstract operator" or "operator abstract", but either works for me
    abstract operator [] (index: Int) -> Int
    getFirst: func -> Int {
        this[0]
    }
}

PunyMatrix: class extends Matrix {
    a, b, c, d : Int
    init: func (=a, =b, =c, =d)
    operator [] (index: Int) -> Int {
        match (index) {
            case 0 => matrix a
            case 1 => matrix b
            case 2 => matrix c
            case 3 => matrix d
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants