A record in the class definition that begins with no access type is a
collective attribute. It is not created for any particular class member, but belongs to the class
itself.
Currently only three collective attributes can be defined, which are
- title: must be a character string. It is meant to give a brief
description of the purpose or functionality of the class.
- new: must be a function. It is
the constructor of the class, and used to create new members of the class.
- super: must be a class or a list of classes. It is the super class(es)
from which the current class inherit attributes.
All the collective attributes are optional. The following is a class which has all the three
collective attributes.
global.circle = class
super = global.ellipse;
title = "circle";
new = radius -> ();
public radius = 1 in _RP;
auto longaxis = () -> parent.radius;
auto shortaxis = () -> parent.radius;
auto area = () -> pi * (parent.radius)^2;
auto perimeter = () -> 2 * pi * parent.radius;
end
oz
2009-12-22