Attribute name clash

When defining a class, attributes must have different names. However, an attribute inherited from a super class may have the same name with an attribute defined in the class itself. And attributes with same names may be inherited from different super classes. In Shang the attribute defined in a class definition always has higher precedence than inherited attributes. For example, if class z has a member attribute bark but also inherits a member attribute bark from a super class. If m is a member of z, then m.bark refers to the attribute defined in z not in the super class. But if z doesn't have a bark attribute, m.bark of course refers to the attribute of the super class.

If there is a name clash, the keyword as can be used to clarify which class is referred to. For example, if m belongs to both S class and T class, and both classes have member attribute fern, then one can use (m as S).fern or (m as T).fern to eliminate the ambigulty.

oz 2009-12-22