public

A public attribute is accessible to and modifiable by both attribute functions of the same member and the surrounding scope of the member. For example
   circle = class 
              public radius = 1;
              auto   perimeter = () -> 2 * pi * parent.radius;
              auto   area = () -> pi * (parent.radius)^2;
            end
in which radius is a public attribute, and perimeter and area are two auto attributes. If x is a circle, then one can use x.radius to find its radius, and use x.radius = new_value to reset its radius to a new value. The new value assigned to a public attribute must belong to the domain of the attribute, which, by default, is _ALL.

Inside an attribute function, to access another attribute of the same member of the class, the keyword parent must be used. In the above example, if x is a member of circle class, then in the surrounding scope of x, the radius of x is x.radius, while inside an attribute function (such as perimeter and area) of x the radius of x is referred to as parent.radius.



oz 2009-12-22