Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reflective conformance: TraitRef and implements

  • TraitRef is a reflective sort parallel to TypeRef (RFD 0023): values are handles to declared traits (carrier Value::Name). It is a sibling sort under Entity — deliberately not on the Metatype <: TypeRef chain, because traits are not types.
  • implements(t: TypeRef, tr: TraitRef) -> Bool is the fifth reflection intrinsic (Reflection), materialized as the RT-closed reserved-head relation $implements from impl declarations, with supertrait closure and <: upward target-coverage folded in (an impl for Person covers USPerson, World assumptions (CWA / OWA)-coherent).
  • $implements is catalog-closed, so not implements(…) is stratification-safe, and — unlike the type-position arguments of the other four intrinsics — both positions of implements are exempt from OE0212 and may be free: enumeration is relational (implements(t, Adulthood) with free t yields the implementing types; implements(meta(p), tr) with free tr yields the traits of p’s type). The expression plane gets the boolean form (if/match scrutinees) and implementors(Trait) -> Set<TypeRef>.
  • Conformance checks are catalog-level vocabulary under RFD 0025 D1 as amended by RFD 0026 (catalog-level iff every variable is reflective-sorted: TypeRef, TraitRef, or Metatype), so they discharge statically at ox check:
#[static]
pub check EveryPersonKindHasAdulthood(t: TypeRef) :-
    specializes(t, Person),
    not implements(t, Adulthood)
    => Diagnostic {
        severity: Severity::Error,
        code:     "Onto::E001",
        message:  format!("{} must implement Adulthood", t),
    }