Namespace - Probabilistic Name Collisions and Ambiguity in Classes
In a recent conversation about C++ and Java, a person I spoke with seemed very adamant that in sub-classing, both programming languages were inadequate about resolving ambiguity - particularly in multiple inheritance. C++ has full multiple inheritance, Java has interface is kind of multiple inheritance (but have to re-implement inherited methods), Mynx uses multiple disjoint. The major point seemed to be that ambiguity occurs (not with Java as you must re-implement, so its a deficiency and a strength) but the programming languages should facilitate avoiding ambiguity. My point was that handling ambiguity is more important than trying to prevent it.
Ambiguity needs to be quantified. In C++ it is a question of which method for a given name from a super-class is used in the sub-class. Mynx is strict in that there is no ambiguity as any super-classes must be disjoint. C++ a good compiler will indicate a problem in determing which super-class method is referenced, but back when C++ was the hot new object-oriented language, some compilers used an ad hoc approach - it was up to the compiler writer.
One point I made in this conversation is that language ambiguity is from the language designer - an unresolved point that needs to be resolved formally. Beyond that though, the question of making the programming language able to handle ambiguity is a feature if not present is a moot point.
Collisions in the namespace are avoided with a module or package - a namespace construct. The class name is part of the namespace for which the class elements of attributes and methods are enclosed.
While the namespace mechanism is avoiding a problem with name collisions, it does not guarantee a collision will not occur. Java uses a namespace with the Internet domain and other information. That helps, but it still possible to have collisions by classes create within the same organization such as a institute, educational organization, or large company. Names can collide because the same name has different meanings.
Once I worked with a database, and one of the tables was “TEMP” - which for a software developer is a temporary table. In actuality the table was for temperature - in a climatology database. TEMP as a name is ambigious, and a collision from two different perspectives - one computer science, the other climate. Hence a name collision can occur from different domains of science using an identifier mnemonic with multiple meanings. (And the database was very amateurish - reflected in the grossly ambigious and vague names used for tables).
The idea of using a language construct to resolve ambiguity is dependent on the degree of collision avoidance, if two classes names of methods collide, all the ambiguity resolution might not help. Prevention helps to avoid, but does not completely avoid namespace ambiguity in a name collision. Prevention and a language mechanism to resolve ambiguity (a reverse prevention) do not handle the problem as discussed.
As prevention is not a solution, thus it follows need a means to handle name collisions and super-class reference ambiguity. Mynx has two programming language features:
1. Privatize a method in a class;remove or mask ambigious name - obviate.
2. Rename a method or all methods for a name - method equivalents.
Mynx avoids C++ ambiguity by requiring that class names, and class element names are disjoint. The Mynx compiler will not have to use an ad hoc approach, it is a critical semantic error.
The language features of Mynx allow two possibilities:
1. Sub-class classes with common names, and rename to unique, then inherit those classes. N-classes externally resolved to one class.
2. In the sub-class, rename the methods and/or obviate the duplicate method names - more compiler work to verify internal and external semantics. N-classes internally resolved to one class.
Language features must work to resolve and handle the unanticipated. The software developer as (using an artist metaphor) a painter needs the tools in their palette to be able to handle the unanticipated in painting a canvas.
A programming language must avoid adding a new feature for every possibility and nuance; the language must have the capacity to adapt - from the features in the language. One reason why C is around (and not a fad like some claim) but Pascal has now fallen by the wayside is that C can handle the twists and turns in the software development labryinthe over time. Pascal required proprietary extension.
The concept of adaptivity of a programming language is malleability - if a programming language can adapt, or brittle if it is inflexible.
Ambiguity needs to be quantified. In C++ it is a question of which method for a given name from a super-class is used in the sub-class. Mynx is strict in that there is no ambiguity as any super-classes must be disjoint. C++ a good compiler will indicate a problem in determing which super-class method is referenced, but back when C++ was the hot new object-oriented language, some compilers used an ad hoc approach - it was up to the compiler writer.
One point I made in this conversation is that language ambiguity is from the language designer - an unresolved point that needs to be resolved formally. Beyond that though, the question of making the programming language able to handle ambiguity is a feature if not present is a moot point.
Collisions in the namespace are avoided with a module or package - a namespace construct. The class name is part of the namespace for which the class elements of attributes and methods are enclosed.
While the namespace mechanism is avoiding a problem with name collisions, it does not guarantee a collision will not occur. Java uses a namespace with the Internet domain and other information. That helps, but it still possible to have collisions by classes create within the same organization such as a institute, educational organization, or large company. Names can collide because the same name has different meanings.
Once I worked with a database, and one of the tables was “TEMP” - which for a software developer is a temporary table. In actuality the table was for temperature - in a climatology database. TEMP as a name is ambigious, and a collision from two different perspectives - one computer science, the other climate. Hence a name collision can occur from different domains of science using an identifier mnemonic with multiple meanings. (And the database was very amateurish - reflected in the grossly ambigious and vague names used for tables).
The idea of using a language construct to resolve ambiguity is dependent on the degree of collision avoidance, if two classes names of methods collide, all the ambiguity resolution might not help. Prevention helps to avoid, but does not completely avoid namespace ambiguity in a name collision. Prevention and a language mechanism to resolve ambiguity (a reverse prevention) do not handle the problem as discussed.
As prevention is not a solution, thus it follows need a means to handle name collisions and super-class reference ambiguity. Mynx has two programming language features:
1. Privatize a method in a class;remove or mask ambigious name - obviate.
2. Rename a method or all methods for a name - method equivalents.
Mynx avoids C++ ambiguity by requiring that class names, and class element names are disjoint. The Mynx compiler will not have to use an ad hoc approach, it is a critical semantic error.
The language features of Mynx allow two possibilities:
1. Sub-class classes with common names, and rename to unique, then inherit those classes. N-classes externally resolved to one class.
2. In the sub-class, rename the methods and/or obviate the duplicate method names - more compiler work to verify internal and external semantics. N-classes internally resolved to one class.
Language features must work to resolve and handle the unanticipated. The software developer as (using an artist metaphor) a painter needs the tools in their palette to be able to handle the unanticipated in painting a canvas.
A programming language must avoid adding a new feature for every possibility and nuance; the language must have the capacity to adapt - from the features in the language. One reason why C is around (and not a fad like some claim) but Pascal has now fallen by the wayside is that C can handle the twists and turns in the software development labryinthe over time. Pascal required proprietary extension.
The concept of adaptivity of a programming language is malleability - if a programming language can adapt, or brittle if it is inflexible.
Labels: ambiguity, inheritance ambiguity, malleability, name collisions

