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

[Feature] Generic (interface) constraints #64

Open
alexnask opened this issue May 10, 2016 · 3 comments
Open

[Feature] Generic (interface) constraints #64

alexnask opened this issue May 10, 2016 · 3 comments

Comments

@alexnask
Copy link

I vaguely remember this exact issue being discussed in some ooc-lang/rock issue but I am basically talking about this kind of stuff:

Comparable: interface {
    greater?: func(other: This) -> Bool
    lesser?: func(other: This) -> Bool
}

f: func <T: Comparable> (a, b: T, g: Func) {
    if (a greater?(b)) {
        g()
    }
}

Basically, the above would be equivalent to:

f: func (a, b: Comparable, g: Func) {
    if (a greater?(b)) {
        g()
    }
}

But make sure that a, b are of the same type (or have a common root type).

@marcusnaslund
Copy link

Do you mean this one? ooc-lang#822

@alexnask
Copy link
Author

@marcusnaslund

Oops, I thought it was just a tangent discussion on a closed issue.
This is indeed the issue I was referring to.

@alexnask
Copy link
Author

alexnask commented May 10, 2016

My knowledge on the way interfaces are implemented in the runtime is probably the shakiest out of all ooc features.

I will be looking into it in more depth and fixing as many bugs as possible and possibly implementing this (although this would probably be a part of the much needed typearg system rewrite).

@alexnask alexnask changed the title Generic (interface) constraints [Feature] Generic (interface) constraints May 10, 2016
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