Skip to content

0.9.12-M2

Pre-release
Pre-release
Compare
Choose a tag to compare
@neko-kai neko-kai released this 15 Nov 15:05
· 2246 commits to develop since this release

distage:

Added new ModuleDef syntax bind for binding a single implementation to multiple interfaces:

new ModuleDef {
  bind[ImplXYZ]
    .to[X]
    .to[Y]("special")
    .to[Z]
  make[User]
}

where User:

// User doesn't have to know that both X and Y
// are the same instance of ImplXYZ, it only knows
// of separate interfaces
class User(
  x: X,
  y: Y @Id("special"),
) {
  ...
}

Desugaring:

  bind[ImplXYZ]
    .to[X]
    .to[Y]("special")
    .to[Z]

<=>

  make[ImplXYZ]
  make[X].using[ImplXYZ]
  make[Y].named("special").using[ImplXYZ]
  make[Z].using[ImplXYZ]
  • Binding implementation to multiple interfaces (#652)