new
new — creates a new instance of a class.
new (class)
classThe name of an existing class.
A new instance of the class.
The new function creates a new instance of the
specified class and initializes any instance variables which have default
values associated with them, or assigns them to nil if there is no default
specified.
An instance is represented by an open brace, followed by the class name,
followed by a sequence of dotted pairs (dotted lists of two elements), each
containing an instance variable name and a value, followed by a closing
brace. Note that (x . nil) is the same as
(x). For example, an object of the class
PhPoint would be {PhPoint (x . 5) (y .
0)}.
An instance can be destroyed by destroy.
Gamma>class RegPolygon{sides; length;}(defclass RegPolygon nil [][length sides])Gamma>class Square RegPolygon {sides = 4;}(defclass Square RegPolygon [][length (sides . 4)])Gamma>polyA = new(RegPolygon);{RegPolygon (length) (sides)}Gamma>sqC = new(Square);{Square (length) (sides . 4)}Gamma>