Skip to content

Default implementations in interfaces #40

@SamTebbs33

Description

@SamTebbs33

Functions declared in interfaces should be able to contain default implementations. Functions without a default implementation would require an implementation in a sub-class, but functions with a default implementation would not require an implementation in a sub-class.

interface Comparable<T> {
    func <(obj : T) : bool
    func ===(obj : T) : bool
    func <=(obj : T) : bool -> this < obj || this === obj
    func >(obj : T) : bool -> !(this <= obj)
    func >=(obj : T) : bool -> this === obj || !(this < obj)
}
class A : Comparable<A> {
    override func <(obj : T) : bool {
        // Implementation-specific code
    }
    override func ===(obj : T) : bool {
        // Implementation-specific code
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions