Skip to content

[Feature] Generic (interface) constraints #64

@alexnask

Description

@alexnask

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions