The reasons for this decision were manyfold:
- I could save a huge amount of work by not programming byte code generation, even if there exist excellent libraries for this nowadays.
- The Java compiler would check whether the code produced by Frege code generation made sense.
- If it did not make sense, one could easily see it, by just looking at the java code, which, incidentally, contains also the desugared Frege code in the form of comments.
- Last but not least, for an old-fashioned UNIX hacker like me, it felt like the most natural way to do.
A first warning came early, when the Java 6 compiler complained about syntax errors. It turned out that this was instead a Java compiler bug. Astonishing, a few years after introduction of generics in the language! Worse, the bug would only get fixed with JDK7. See my stackoverflow post for details.
Fortunately, at this time the JDK7 preview was already available, so I downloaded that and continued with JDK7.
Some days later I discovered that I could not express the type of a class method of a constructor type class, like this:
Here, the type variable f stands not for a type, but for a partially applied type, like Maybe or , and the variables a and b are like the element types.
As I had to learn this way, Java has not the slightest idea of how to apply a type variable to a type. I wasted a week or so trying with something like
but other difficulties arose I can't recall exactly, but they were insurmountable.
Not enough that type applications would not work with variables, partially applied types would not work either. Don't ask what I experienced with higher ranked function types like
Yet, my desire to see Frege compiled code run finally, and, when this was achieved, the aversion against throwing everything away and starting anew, seduced me to write one workaround after the other, every time in the hope it would be the last one. For example, I introduced methods like this:
Until recently, when one of the committers of the Frege project found a number of bugs, and two or three of them were of the sort where the Java compiler flags type errors. Today, he sent me another error report with the following compiler message:
est.Test.tMaybe<?>>>) in test.Test.iMonad_Maybe._gt_gt_
return iMonad_Maybe._gt_gt_eq.<Fun<?, ?>, ?>w(_arg1, _â2805_27)._e();
Yes, it can be applied, I just can't prove it in Java!
Time for a new code generation without generics, but with unavoidable explicit casts in the right places! This will mostly be a matter of stripping the generic overhead of maybe 30% to 40% off the current code generator.