Skip to content

Traits instead of interfaces? #24

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> {
    // [...]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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