parent_class

parent_class — returns the closest parent (base) of a class or instance.

Syntax

parent_class (instance|class)

		

Arguments

instance|class

An instance of a class; or a class.

Returns

The closest parent (base) class of the instance or class.

Description

This function returns the closest (immediate) parent (base) class of the class or instance provided.

Example

Gamma> class RegPolygon{sides; length;}
(defclass RegPolygon nil [][length sides])
Gamma> class Square RegPolygon {sides = 4;}
(defclass Square RegPolygon [][length (sides . 4)])
Gamma> class BigSquare Square {length = 30;};
(defclass BigSquare Square [][(length . 30) (sides . 4)])
Gamma> polyA = new(RegPolygon);
{RegPolygon (length) (sides)}
Gamma> sqC = new(Square);
{Square (length) (sides . 4)}
Gamma> bigD = new(BigSquare);
{BigSquare (length . 30) (sides . 4)}
Gamma> parent_class(polyA);
nil
Gamma> parent_class(sqC);
(defclass RegPolygon nil [][length sides])
Gamma> parent_class(bigD);
(defclass Square RegPolygon [][length (sides . 4)])
Gamma> parent_class(Square);
(defclass RegPolygon nil [][length sides])
Gamma> parent_class(BigSquare);
(defclass Square RegPolygon [][length (sides . 4)])
Gamma> 
		

See Also

class