Type Command Example
Details
Action
Defines a Class Type in the MathScript Object Hierarchy. Once the class type is defined, objects of that type may be created using
the Object Command. Types of objects form a tree with each type subordinate to a number
of parent types (or to none, if the type is a root). Object types have instance variables of their own, and inherit the instance variables of their parents and other
ancestors. Each type of object may access (get or set) these variables by
sending itself or other types of objects messages. If the type has an instance variable with the same name as a parent, the local
variable overrides the parent variable. Types also encapsulate methods for taking actions, and those methods are triggered by sending messages.
When an object receives a message to implement a method, it looks first to see if
its type has the method to handle it. If not, it begins a breadth-first search
among parent types until it finds a type with the appropriate method. Again,
if type type has a method with the same name as a parent method, the local
method overrides the parent method.
type screen list(window, objs, selection, numobjs) list();
Declares a type called "screen" . The instance variables are "window",
"objs", "selection", and "numobjs". This type has no parent types, hence is
declared with the empty list ( list() ).
type geobj list(border, fill, width, center, selected, vertices, pname) list();
Declares a type called "geobj" . The instance variables are "border",
"fill", "width", "center", "selected", "vertices", and "pname". This type has no
parent types, hence is declared with the empty list ( list() ).
type poly list(order) list(geobj);
Declares a type called "poly" . The instance variable is "order". But this
inherits the instance variables: "border", "fill", "width", "center",
"selected", "vertices", and "pname" from its parent type: "geobj". This parent type,
is declared with the list ( list(geobj) ).
type circle list(order, radius) list(geobj);
Declares a type called "circle" . The instance variables are "order", and
"radius". But this inherits the instance variables: "border", "fill", "width",
"center", "selected", "vertices", and "pname" from its parent type: "geobj".
The parent type, is declared with the list ( list(geobj) ).