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.
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? |
Call the classname operator.
onyx:0> vclass:classname 1 sprint $vclass onyx:0>
Call the data operator.
onyx:0> vclass:data 1 sprint <> onyx:0>
Define key as val in the data dictionary of the current class or instance.
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>
Call the implementor operator.
onyx:0> class dup vclass setsuper onyx:1> $new exch :implementor:classname 1 sprint $vclass onyx:0>
Call the implements operator.
onyx:0> $new vclass:implements 1 sprint true onyx:0> $foo vclass:implements 1 sprint false onyx:0>
Call the isa operator.
onyx:0> instance isa 1 sprint null onyx:0> vclass:new:isa:classname 1 sprint $vclass onyx:0>
Call the kind operator.
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>
Call the method operator.
onyx:0> $fooclass class dup vclass setsuper def onyx:0> $new fooclass:method 1 sprint {--instance-- --dup-- --dn-- --setisa-- --dup-- --dict-- --setdata--} onyx:0>
Call the methods operator.
onyx:0> vclass:methods 0 sprint -dict- onyx:0>
Constructor.
onyx:0> vclass:new 1 sprint -instance- onyx:0>
Recursively call superclass's constructor ( new ). This method is typically only used internally by constructors.
onyx:0> $fooclass vclass <><$new {:rnew}> cdef onyx:0> fooclass:new:isa:classname 1 sprint $fooclass onyx:0>
Call the setclassname operator.
onyx:0> $fooclass class dup vclass setsuper def onyx:0> $fooclass fooclass:setclassname onyx:0> fooclass:classname 1 sprint $fooclass onyx:0>
Call the setdata operator.
onyx:0> $fooclass class dup vclass setsuper def onyx:0> <$foo `foo'> fooclass:setdata onyx:0> fooclass:data 1 sprint <$foo `foo'> onyx:0>
Call the setisa operator.
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>
Call the setmethods operator.
onyx:0> $fooclass class dup vclass setsuper def onyx:0> <$foo `foo'> fooclass:setmethods onyx:0> fooclass:methods 1 sprint <$foo `foo'> onyx:0>
Call the setsuper operator.
onyx:0> $fooclass class dup vclass setsuper def onyx:0> fooclass:super:classname 1 sprint $vclass onyx:0>
Call the super operator.
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>
Undefine key in the data dictionary of the current class or instance.
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>