Any or Only Methods -- What are class methods made of?
In Mynx, issues of types and casts arise, particularly now as I implement the semantic checks. The basic problem or question is over ease of use versus strong or strict typing. The difficulty becomes more complex when considering that operator overloading is essentially associating an operator with a unary parameter method.
Any or only methods specify an instance or class method - whether the method may be overloaded (multiple methods of different parameters with the same name), or overridden (re-define the method in a sub-class derived from a super-class).
An only method can only (no pun intended...) be overridden, not overloaded. This property can be useful for creating methods of a specific purpose or function.
Example illustrating only method:
The method "isEqual" can be exclusively overridden, but not overloaded. An example of overloading an only method is:-
An example of correctly overrriding an only method is:-
In the examples, a method for class equality relation is exclusively the kind of method for that purpose. The isEqual method requires method overriding and forbidding overloading.
An only method is advantageous in that it simplifies a class considerably. In the context of the "binary method problem" of determining type, there is but a specific method in the class hierarchy.
Any is the converse and the implicit default behavior for a class method -- the method can be overriden or overloaded.
The fragment of Extended Backus-Naur syntax is:
The any or only keyword specifiers specify as only one or many (1:N) -- method cardinality (to borrow a term from set theory).
Specific examples of methods:
The 'any' keyword allows to declare explicitly what is implicit (an important design principle of Mynx).
This feature is not present in Mynx, but in the process of implementing the semantic checks, and looking ahead to high-level language code synthesis, this feature appears to have a usefulness not found in the "Big Three" languages of C++, Java, and C#.
Any or only methods specify an instance or class method - whether the method may be overloaded (multiple methods of different parameters with the same name), or overridden (re-define the method in a sub-class derived from a super-class).
An only method can only (no pun intended...) be overridden, not overloaded. This property can be useful for creating methods of a specific purpose or function.
Example illustrating only method:
virtual class VObject is
public only default Bool isEqual(in VObject);
end class;
The method "isEqual" can be exclusively overridden, but not overloaded. An example of overloading an only method is:-
class badMethod as VObject is
//COMPILER ERROR - only overloaded, not override doh!
public default Bool isEqual(in Object obj) is
//...method definition...
end isEqual;
end class;
An example of correctly overrriding an only method is:-
class goodMethod as VObject is
//COMPILER VALID - method is overridden, not overloaded.
public default Bool isEqual(in VObject vobj) is
//...method definition...
end isEqual;
end class;
In the examples, a method for class equality relation is exclusively the kind of method for that purpose. The isEqual method requires method overriding and forbidding overloading.
An only method is advantageous in that it simplifies a class considerably. In the context of the "binary method problem" of determining type, there is but a specific method in the class hierarchy.
Any is the converse and the implicit default behavior for a class method -- the method can be overriden or overloaded.
The fragment of Extended Backus-Naur syntax is:
ACCESS ['any' | 'only'][mode][type] IDENTIFIER...The any or only keyword specifiers specify as only one or many (1:N) -- method cardinality (to borrow a term from set theory).
Specific examples of methods:
public virtual myVClass is
public only String toString;
public any Bool isEqual(in VObject);
public Int doHash(in myVClass);
end class;
The 'any' keyword allows to declare explicitly what is implicit (an important design principle of Mynx).
This feature is not present in Mynx, but in the process of implementing the semantic checks, and looking ahead to high-level language code synthesis, this feature appears to have a usefulness not found in the "Big Three" languages of C++, Java, and C#.
Labels: binary method problem, class method, overload, override


<< Home