private

A private member attribute is not visible outside the definition of the class, but can be accessed and modified by other attribute functions of the class member. For example
>>   circle = class 
              private radius = 1;
              common  getRadius = () -> parent.radius;
              // access parent.radius is ok here
              common  setRadius = function x  ->  ()
                                       if x > 0
                                            parent.radius = x;
                                       end
                                  end
              auto    perimeter = () -> 2 * pi * parent.radius;
              auto    area = () -> pi * (parent.radius)^2;
            end
>>   p = circle.new();
>>   p.radius;  // Error: accessing private attribute
>>   p.getRadius()
       1
>>   p.setRadius(12);
>>   p.getRadius();
       12
Here radius is private attribute and cannot be accessed outside the class. But other attribute functions (getRadius and setRadius) can access it using the parent keyword.



oz 2009-12-22