ammer

Linking subdefinitions

In addition to libraries, ammer offers four kinds of "subdefinitions":

Each declaration declares a link to the parent library (e.g. ... extends ammer.Sublibrary<ParentLibrary>). However, a corresponding backlink should also be declared on the parent library, using the @:ammer.sub metadata. Although this declaration is optional (for the time being), it is recommended to avoid certain compilation errors, especially if the subdefinitions are declared in separate files. See type cycles for a technical explanation.

Example: linking a sublibrary

// in file Foobar.hx
@:ammer.sub((_ : FoobarSub))
class Foobar extends ammer.def.Library<"foobar"> {}

// in file FoobarSub.hx
class FoobarSub extends ammer.def.Sublibrary<Foobar> {}

In this example, Foobar links to its sublibrary using the @:ammer.sub metadata. FoobarSub links to its parent library using the type parameter of ammer.def.Sublibrary.

« Previous: Callbacks Next: Configuration »