Re: Still no typedef
Patricia Shanahan wrote:
"typedef" is not currently a Java keyword. Here's an alternative syntax
suggestion:
class FooInt Foo<Comparator<Integer>>;
How about a bit different syntax for /type aliasing/ (good term?):
class FooInt = Foo<Comparator<Integer>>;
?
Of course, "tell the truth" rule is still needed, e.g.:
interface IntComparator = Comparator<Integer>;
class FooInt = Foo<IntComparator>;
The existing class declaration syntax does not allow the identifier
to be immediately followed by another identifier.
Yes, your proposal is enough, but with equals sign it seems to be
clearer that there is no new type defined (at least to me). It's just a
compile time defined type alias for already existing type.
Declaration scope
could be controlled by the same rules as for existing class declarations.
These rules may probably be reused. However, a maximum scope available
for alias should be likely a single compilation-unit. I'm afraid that
wider scope is to complex to become worthy of implementing in the
language. Without that needed, the compiler shall simply resolve each
alias to the real type.
In any case, I'm another one who'd like to have the type aliasing
feature available in Java.
piotr