Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit0a13e47b57

README.md

interfaces (module)

Which interfaces a type implements, and whether its declaration keeps them. The one owner of the question: ref:implements, ref:as, the gate, listings and the inspector all ask here.

An interface is an interface asset (<name>.interface/) stating a guarantee: members with signatures, and properties. A type lists the interfaces it implements under interfaces: in its type.yaml; assetType.assetType declares that key a reference to interface assets, so every listed name is recorded by guid in the type definition's reference table. A type's marks are read from those references, and every asset of the type implements every interface the type lists.

Exports

  • M.of(typeName) -> { typeName, marks, problems, declared } — the marks a consumer may rely on and every problem the declaration raised. A declaration with an error carries no marks. Held until the type's files, an interface it lists, or the set of interfaces changes.
  • M.typeImplements(typeName, x) -> boolean — whether the type implements the interface x (name, identity or guid), or any of a list of them.
  • M.markOf(typeName, x) -> Mark? — the mark, with its source (declared or implied) and which members are met explicitly.
  • M.member(typeName, mark, name) -> (function?, explicit) — the function that meets a member now: M.interfaces.<interface>.<member>, else M.ref.<member>.
  • M.definitionOf(ref) -> Definition — an interface asset's interface.yaml, read: members with parsed signatures, properties, type keys, contract, conformance, legacy member.
  • M.resolveInterface(x) -> (ref?, "unknown" | "ambiguous"?, candidates?).
  • M.checkProperty(property, value), M.propertyTypeText(kind).
  • M.forget() — drop every held answer. The change dispatcher calls it for a write inside an .interface or .assetType folder and for their removal.
  • M.declareReferenceKeys() -> number — declare every key a type's type.yaml states under references.interfaceKeys ({ key, implements, field?, via? }) through asset.declareReferenceKey, typed to the categories that implement the interface now. Boot registration calls it once every type has registered; M.scheduleReferenceKeys() runs it at the end of the frame, and the change dispatcher calls that after a change to a type or an interface.

Refusals

A declaration is refused, and carries no marks, while any of these stands: interfaces.shape, interfaces.unknown, interfaces.ambiguous, interfaces.duplicate, interfaces.missing, interfaces.arity, interfaces.typeKey, interfaces.explicitUnclaimed, interfaces.explicitUnknown, interfaces.propertyMissing, interfaces.propertyType, interfaces.conflict, interfaces.unloadable. interfaces.implied is a warning and refuses nothing. Each message names the type, the file, the fault and what to write; the assetType type's validate reports them, and the engine log states each once per state of the declaration.

A type that lists no interfaces: key and defines the member an interface names under legacy: { implied_by } is marked with that interface, source implied.