Skip to content

Traits instead of interfaces? #24

@Doom2fan

Description

@Doom2fan

We could have traits instead of interfaces, while still allowing "trait inheritance". This would mean classes and structs can explicitly implement a trait internally, while also allowing external "extension" of types with traits. e.g.

trait Iterator!(T, TState) {
    TState InitialState ();
    T? TryGetNext (ref TState state);
}

extends IList!(T) with Iteratable!(T, intN) {
    intN InitialState => 0;
    T? TryGetNext (ref intN index) => index < length ? this[index] : null;
}

class ClassWithIterator : Iterator<T, int32> {
    // [...]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions