Own Out of the Mynx Programming Language
The original design of the Mynx programming language has an ‘own’ method in a virtual class - a way of specifying a static method in the equivalent of a Java/C# interface.
An example of an own method in a virtual class:
An implementing class of the VInteger class with an own method is:
Any class that implements the virtual class VInteger must implement a static method parse that returns a VInteger type object.
In principle, a very useful feature - but there is a problem. Consider the following Mynx code fragment:
The problem with an own method is that while a developer can specify a static method in the implementing class by a virtual class, there is no way to access the static method through the virtual class -- the virtual class allows access to instance elements, not static.
There is another nuance to the own method, presuming access to a static method through a virtual class. The Mynx code fragment:
The nuance of the problem is that to use a static method, it needs an instance which mixes static and instance semantics. The second wrinkle is that each static method is used instead of one, so there are multiply different static methods -- just like an instance. The third is simple that if the virtual class name refers to a null, there is no reference for the instance, nor is there for the static reference. The fourth is if a virtual class references two different instances (such as int32 and int64), which static method does it refer to -- some ambiguity.
The underlying semantic flaw is the own method is a feature but a property that does not have a larger semantic entity. Without a larger semantic entity, the instance semantics are intermixed with static semantics.
Hence, the feature is interesting, but because of the problematic nature of the feature, it will be removed from the Mynx language.
As an author and writer, I think of the words of E.B. White "The best writing is re-writing." The same applies equally in programming language design -- re-design. More emphatically, author Mario Puzo: "Rewriting is the whole secret to writing" (Time, 28/8/78) -- restated "Language design is re-design."
An example of an own method in a virtual class:
virtual class VInteger is
public own VInteger parse(in String);
//other integer methods...
end class;
An implementing class of the VInteger class with an own method is:
default class Integer as VInteger is
public static VInteger parse(in String str) is
//...implementation blah...blah...blah
end parse;
end class;
Any class that implements the virtual class VInteger must implement a static method parse that returns a VInteger type object.
In principle, a very useful feature - but there is a problem. Consider the following Mynx code fragment:
Integer int to null;
VInteger vint to null;
vint as Integer(“22”);
int is VInteger.parse(“0”); //error - VInteger has no implementation
int is Integer.parse(“0”); //ok - Integer has implementation
The problem with an own method is that while a developer can specify a static method in the implementing class by a virtual class, there is no way to access the static method through the virtual class -- the virtual class allows access to instance elements, not static.
There is another nuance to the own method, presuming access to a static method through a virtual class. The Mynx code fragment:
Int32 int32 to 32; //implements VInteger - including own method
Int64 int64 to 64; //implements VInteger - including own method
VInteger vint to null;
Integer int to null;
int is VInteger.parse(“0”); //VInteger is null - but static method,
//so can invoke-?? ambiguity
vint is int32; //Int32.parse == VInteger.parse
vint is int64; //Int64.parse == VInteger.parse
The nuance of the problem is that to use a static method, it needs an instance which mixes static and instance semantics. The second wrinkle is that each static method is used instead of one, so there are multiply different static methods -- just like an instance. The third is simple that if the virtual class name refers to a null, there is no reference for the instance, nor is there for the static reference. The fourth is if a virtual class references two different instances (such as int32 and int64), which static method does it refer to -- some ambiguity.
The underlying semantic flaw is the own method is a feature but a property that does not have a larger semantic entity. Without a larger semantic entity, the instance semantics are intermixed with static semantics.
Hence, the feature is interesting, but because of the problematic nature of the feature, it will be removed from the Mynx language.
As an author and writer, I think of the words of E.B. White "The best writing is re-writing." The same applies equally in programming language design -- re-design. More emphatically, author Mario Puzo: "Rewriting is the whole secret to writing" (Time, 28/8/78) -- restated "Language design is re-design."
Labels: interface method, own method, static interface method, static method, virtual class


<< Home