auto

An auto attribute is essentially a special common attribute. It is a read-only function, therefore the values of the attribute for all members of the class are the same as the default value given in the class definition, which is a function, and cannot be modified after the class member is instantiated. But an auto function must take no input argument, and therefore the header looks like
	auto f = function () -> y
                   ...
                   ...
            end
Normally if f has no input argument, it should be called by appending a pair of empty parentheses, as in f(). Here suppose that u is class member. If f were a common attribute, we would have to call it by u.f(). The only difference made by being an auto is now f can be called by u.f without the empty parentheses enclosure. For example
   circle = class 
              public radius = 1;
              auto   perimeter = () -> 2 * pi * parent.radius;
              auto   area = () -> pi * (parent.radius)^2;
            end
If x belongs to the circle class, to find its area, one only needs to write x.area. But manually setting x.area to new value using x.area = new_value is not allowed, since x.area can only be automatically calculated using the attribute function.



oz 2009-12-22