type

Spec

@Js
const mixin Spec : Dict

Xeto data specification.

Spec dict representation:

  • id: Ref "lib:{qname}"
  • spec: Ref "sys::Spec"
  • base: Ref to base type (types only)
  • type: Ref to slot type (slots only)
  • effective meta

methods

_id

Identifier for a spec is always its qualified name This is a temp shim until we move haystack::Dict fully into Xeto.

base

Base spec from which this spec directly inherits its meta and slots.

fits

Return if spec this spec fits that based on structural typing.

isMaybe

Does meta have maybe tag

isa

Return if this spec inherits from that from a nominal type perspective.

lib

Parent library for spec

meta

Get my effective meta; this does not include synthesized tags like spec

metaOwn

Get my own declared meta-data

name

Return simple name scoped by lib or parent.

parent

Parent spec which contains this spec definition and scopes name.

qname

Return fully qualified name of this spec

slot

Convenience for slots.get

slotOwn

Convenience for slotsOwn.get

slots

Get the effective children slots including inherited

slotsOwn

Get the declared children slots

type

Type of this spec.

Slot Details

_id

abstract Ref _id()

Identifier for a spec is always its qualified name This is a temp shim until we move haystack::Dict fully into Xeto.

base

abstract Spec? base()

Base spec from which this spec directly inherits its meta and slots. Returns null if this is sys::Obj itself.

fits

abstract Bool fits(Spec that)

Return if spec this spec fits that based on structural typing.

isMaybe

abstract Bool isMaybe()

Does meta have maybe tag

isa

abstract Bool isa(Spec that)

Return if this spec inherits from that from a nominal type perspective. Nonimal typing matches any of the following conditions:

  • if that matches one of this inherited specs via base
  • if this is maybe and that is None
  • if this is And and that matches any this.ofs
  • if this is Or and that matches all this.ofs (common base)
  • if that is Or and this matches any of that.ofs

lib

abstract Lib lib()

Parent library for spec

meta

abstract Dict meta()

Get my effective meta; this does not include synthesized tags like spec

metaOwn

abstract Dict metaOwn()

Get my own declared meta-data

name

abstract Str name()

Return simple name scoped by lib or parent.

parent

abstract Spec? parent()

Parent spec which contains this spec definition and scopes name. Returns null for top level specs in the library.

qname

abstract Str qname()

Return fully qualified name of this spec:

  • Type specs will return "foo.bar::Baz"
  • Global slots will return "foo.bar::baz"
  • Type slots will return "foo.bar::Baz.qux"
  • Derived specs will return "derived123::{name}"

slot

abstract Spec? slot(Str name, Bool checked := true)

Convenience for slots.get

slotOwn

abstract Spec? slotOwn(Str name, Bool checked := true)

Convenience for slotsOwn.get

slots

abstract SpecSlots slots()

Get the effective children slots including inherited

slotsOwn

abstract SpecSlots slotsOwn()

Get the declared children slots

type

abstract Spec type()

Type of this spec. If this spec is a top level type then return self.