Skip to content

Defer implemented by? #63

@LeaVerou

Description

@LeaVerou

The current proposal defines an implemented by syntax for protocols to include implementations for certain existing classes:

protocol Foldable {
  // ...

  implemented by Array {
    foldr (f, memo) {
      // implementation elided
    }
  }
}

Is this MVP, given this can already be done via Protocol.implement()?

protocol Foldable {
  // ...
}

Array.prototype[Foldable.foldr] = function foldr (f, memo) {
  // implementation elided
};
Protocol.implement(Array, Foldable);

How common is the use case of implementing protocols on built-ins, inline? Is it worth having dedicated syntax sugar, this early?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions