Next: 2.12.2 mclass Up: 2.12 Class reference Previous: 2.12 Class reference Contents Index

##
2.12.1 vclass

The vclass class serves as a base class from which a class hierarchy can be built. Although there are no mechanisms that force the use of vclass when constructing a class hierarchy, it usually makes sense to do so, since the operators that implement object-oriented programming support provide mechanisms, but almost no policy. vclass provides what little policy is needed, such as the naming and invocation of constructors.

Table 2.12: vclass summary
Input(s) Method Output(s) | Description
Class-context methods
- new instance | Constructor.
- rnew instance | Construction helper.
name implementor class/null | Get class that implements name.
name implements boolean | Does class implement name?
name method method | Get class method by name.
- classname name/null | Get class's name.
name/null setclassname - | Set class's name.
- super super/null | Get class's superclass.
super/null setsuper - | Set class's superclass.
- methods dict/null | Get methods dict for class.
dict/null setmethods - | Set methods dict for class.
Class/instance-context methods
- data dict/null | Get data for class/instance.
dict/null setdata - | Set data for class/instance.
key val def - | Define key as val in class/instance data dict.
key undef - | Undefine key in class/instance data dict.
Instance-context methods
- isa class/null | Get class for instance.
class/null setisa - | Set class for instance
class kind boolean | Is class in instance's inheritance hierarchy?

- classname name/null:
  Input(s):
    None.
  Output(s):
    name/null:
      A name or null object.
  Error(s):
    typecheck.
  Description:
    Class-context method.

    Call the classname operator.

  Example(s):

        onyx:0> vclass:classname 1 sprint
        $vclass
        onyx:0>

- data dict/null:
  Input(s):
    None.
  Output(s):
    dict/null:
      A dict or null object.
  Error(s):
    typecheck.
  Description:
    Class/instance-context method.

    Call the data operator.

  Example(s):

        onyx:0> vclass:data 1 sprint
        <>
        onyx:0>

key val def -:
  Input(s):
    key:
      An object.
    val:
      An object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
  Description:
    Class/instance-context method.

    Define key as val in the data dictionary of the current class or instance.

  Example(s):

        onyx:0> $fooclass vclass <><$foo_get {,foo}> cdef
        onyx:0> $foo `foo' fooclass:def
        onyx:0> fooclass:foo_get
        onyx:1> 1 sprint
        `foo'
        onyx:0>

name implementor class/null:
  Input(s):
    name:
      An object of any type, usually a name object.
  Output(s):
    class/null:
      A class or null object.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class-context method.

    Call the implementor operator.

  Example(s):

        onyx:0> class dup vclass setsuper
        onyx:1> $new exch :implementor:classname 1 sprint
        $vclass
        onyx:0>

name implements boolean:
  Input(s):
    name:
      An object of any type, usually a name object.
  Output(s):
    boolean:
      True if name is implemented by class, false otherwise.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class-context method.

    Call the implements operator.

  Example(s):

        onyx:0> $new vclass:implements 1 sprint
        true
        onyx:0> $foo vclass:implements 1 sprint
        false
        onyx:0>

- isa class:
  Input(s):
    None.
  Output(s):
    class/null:
      A class or null object.
  Error(s):
    typecheck.
  Description:
    Instance-context method.

    Call the isa operator.

  Example(s):

        onyx:0> instance isa 1 sprint
        null
        onyx:0> vclass:new:isa:classname 1 sprint
        $vclass
        onyx:0>

class kind boolean:
  Input(s):
    class:
      A class object.
  Output(s):
    boolean:
      True if class is in instance's inheritance hierarchy, false otherwise.
  Error(s):
    typecheck.
  Description:
    Instance-context method.

    Call the kind operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:1> fooclass over:kind 1 sprint
        true
        onyx:1> vclass exch:kind 1 sprint
        true
        onyx:0>

name method method:
  Input(s):
    name:
      An object of any type, usually a name object.
  Output(s):
    method:
      The bottommost method associated with name in class's inheritance hierarchy.
  Error(s):
    stackunderflow.
    typecheck.
    undefined.
  Description:
    Class-context method.

    Call the method operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> $new fooclass:method 1 sprint
        {--instance-- --dup-- --dn-- --setisa-- --dup-- --dict-- --setdata--}
        onyx:0>

- methods dict/null:
  Input(s):
    None.
  Output(s):
    dict/null:
      A dict or null object.
  Error(s):
    typecheck.
  Description:
    Class-context method.

    Call the methods operator.

  Example(s):

        onyx:0> vclass:methods 0 sprint
        -dict-
        onyx:0>

- new instance:
  Input(s):
    None.
  Output(s):
    instance:
      An instance of class.
  Error(s):
    typecheck.
  Description:
    Class-context method.

    Constructor.

  Example(s):

        onyx:0> vclass:new 1 sprint
        -instance-
        onyx:0>

- rnew instance:
  Input(s):
    None.
  Output(s):
    instance:
      An instance of class for which the superclass's constructor has been called.
  Error(s):
    typecheck.
  Description:
    Class-context method.

    Recursively call superclass's constructor ( new ). This method is typically only used internally by constructors.

  Example(s):

        onyx:0> $fooclass vclass <><$new {:rnew}> cdef
        onyx:0> fooclass:new:isa:classname 1 sprint
        $fooclass
        onyx:0>

name/null setclassname -:
  Input(s):
    name/null:
      A name or null object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class-context method.

    Call the setclassname operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> $fooclass fooclass:setclassname
        onyx:0> fooclass:classname 1 sprint
        $fooclass
        onyx:0>

dict/null setdata -:
  Input(s):
    dict/null:
      A dict or null object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class/instance-context method.

    Call the setdata operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> <$foo `foo'> fooclass:setdata
        onyx:0> fooclass:data 1 sprint
        <$foo `foo'>
        onyx:0>

class/null setisa -:
  Input(s):
    class/null:
      A class or null object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Instance-context method.

    Call the setisa operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> fooclass:new
        onyx:1> vclass over:setisa
        onyx:1> :isa:classname 1 sprint
        $vclass
        onyx:0>

dict/null setmethods -:
  Input(s):
    dict/null:
      A dict or null object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class-context method.

    Call the setmethods operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> <$foo `foo'> fooclass:setmethods
        onyx:0> fooclass:methods 1 sprint
        <$foo `foo'>
        onyx:0>

super/null setsuper -:
  Input(s):
    super/null:
      A class or null object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Class-context method.

    Call the setsuper operator.

  Example(s):

        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> fooclass:super:classname 1 sprint
        $vclass
        onyx:0>

- super super/null:
  Input(s):
    None.
  Output(s):
    super/null:
      A class or null object.
  Error(s):
    typecheck.
  Description:
    Class-context method.

    Call the super operator.

  Example(s):

        onyx:0> vclass:super 1 sprint
        null
        onyx:0> $fooclass class dup vclass setsuper def
        onyx:0> fooclass:super:classname 1 sprint
        $vclass
        onyx:0>

key undef -:
  Input(s):
    key:
      An object.
  Output(s):
    None.
  Error(s):
    stackunderflow.
  Description:
    Class/instance-context method.

    Undefine key in the data dictionary of the current class or instance.

  Example(s):

        onyx:0> $fooclass vclass <><$foo_get {,foo}> cdef
        onyx:0> $foo `foo' fooclass:def
        onyx:0> fooclass:foo_get
        onyx:1> 1 sprint
        `foo'
        onyx:0> $foo fooclass:undef
        onyx:0> fooclass:foo_get
        Error $undefined
        ostack: ()
        dstack: (-dict- -dict- -dict- -dict-)
        cstack: (-class-)
        estack/istack trace (0..3):
        0:      ,foo
        1:      :foo_get
        2:      -file-
        3:      --start--
        onyx:1>

Next: 2.12.2 mclass Up: 2.12 Class reference Previous: 2.12 Class reference Contents Index