On Fri, Nov 6, 2009 at 22:14, Reinier Zwitserloot <rein...@gmail.com> wrote:
>
> It's also a ridiculous line of reasoning. Like most things Neal says
> when you attack his proposals, it boils down to overly pedantic drivel
> - technically correct, practically speaking irrelevant or misleading.
>
> Take this very argument, for example: How else would nominal generics
> even work? There's no such thing as nominal generics. You could, I
> guess, create something like:
>
> public typedef StringList extends List of String;
>
> But, as you clearly can't create such a typedef for _every_ type in
> existence out of the box in the java.util package (do we also create a
> StringListListListListMapSetListListSetMap?), the rule would have to
> be that any typedef matching 'List of String' matches any other.
> Regardless of such things as package or name of the typedef. Which is
> simply another take on structural typing.
I disagree with this characterization. I think Neal's line of
reasoning, above is sound and his example of arrays demonstrate this
even more clearly than generics.
With generics, it's at least possible by make a nominal type out of a
structural type by the simple expedient of:
class StringList extends List<String>;
With arrays in Java, we can't even do that. Classes and Interfaces are
the only kinds of types we are allowed to name in Java. This is not
nonsensical, it's merely impossible in *Java*. It's perfectly possible
in a language that's more nominally typed than Java:
TYPE Point3D = ARRAY 3 OF REAL; (* Oberon *)
TYPE String = ARRAY OF CHAR;
Oberon is generally very much nominally typed (as you may know,
judging by the breadth of knowledge demonstrated in your first post on
this tread) supports naming this type. But even in this language,
there is also structural typing. Tellingly, one such case are
procedure types.
TYPE Handler = PROCEDURE (VAR m: Message);
VAR h: Handler;
PROCEDURE DoSomething(VAR m: Message);
BEGIN
END DoSomething;
The variable h, which has a procedural type via the named type Handle
is assignment compatible with the procedure DoSomething (which is a
constant) despite the fact that there is no agreement in their nominal
types. (Procedures don't have nominal types). (How tedious would it be
if we had to name a type for every procedure we wanted to define?)
So, in summary:
(1) Java has always used a mixture of nominal and structural typing.
(2) I consider how procedural types are handled in other languages
I've seen and imagine these design choices were not made without
reason. I suspect that Closures, in particular, would tend to drive a
language designer to structural typing.
We can of course argue about whether adding another case of structural
typing to Java on top of what's already there is a good idea, but
there's no sense in pretending that Java doesn't already mix both
structural and nominal typing.
As to BGGA. I've never liked it. Far too much syntactic and conceptual
complexity for the power it promised. I would have preferred CICE or
better yet FCM, though that never gained much traction.
// (a different) Ben
> Java with BGGA would move java quite a ways towards the left on the
> Structural <-> Nominal typing axis. This is a major change, which has
> a great impact on the feel of java, and it is not necessary for a
> closure proposal, even one that supports full transparency.
>
> Can we all agree on that, instead?
Yes
// Ben