If you are a JJForester user, we would like to know your opinion about possible modifications to the tool. That's what this discussion page is for.
Qualified constructor classes
Industrial application of JJForester has revealed a design flaw.
Currently, the tool puts the generated constructor classes A..Z for a particular sort S in a subpackage S. Like:
package/sorts/S
S/A
...
Z
If Java would allow import statements like:
import package/*;
then the constructor classes could be accessed with:
S.A ... S.Z
But, .... Java does
not allow the import of packages, only of specific classes, or (with *) of all classes in a package. Consequently, one must either import all packages for all sorts separately (leading to name ambiguities if some sorts have constructors with the same name), or one must fully qualify each usage of a constructor class (potentially leading to very long qualifications).
As a solution, I propose not to generate the constructor classes in separate packages per sort anymore, but to generate constructor class names with the sort name as prefix. As in:
package/sorts/S
S_A
...
S_Z
Consequences:
- (+) No need for long lists of import statements.
- (+) No name ambiguities if you import everything in the same scope.
- ( ) Write S_X instead of S.X.
- (-) You can never use constructor class names unqualified anymore.
Questions:
- Have you experienced the problem?
- Would you be happy with my proposed soluton?
- Can you think of a better solution?
Thanks!
--JoostVisser
LeonMoonen? suggested to provide the option between subpackages per sort and underscores via a command line switch.
Of course, instead of importing a package you can add it to your class path, thus making it a root package. Then, ambiguitiy resolution with S.X works!
--JoostVisser