disjoint types are structural in that you weaken the namespacing of
members.

Members are only namespaced by virtue of their container. So lets say
I do this (I apologize in advance for the cliché factor of this
example):

public class com.ren.Gun {
    public void shoot() { System.out.println("BANG!"); }
}

public class com.stimpy.Camera {
    public void shoot() { System.out.println("Smile!"); }
}

public void pointAndClick(Gun | Camera object) {
    object.shoot();
}


should that be legal code? I'd argue no - the fact that both Gun and
Camera have a 'shoot' method is a pure coincidence. They aren't the
same thing at all. Instead, I'd say that such a disjoint type should
only have the members of the common superclass (in this case, that
would be as if 'object' is an Object and no more), with the caveat
that you can pattern match on it. If you indeed cannot call shoot() on
the union of Camera and Gun, it's 100% nominal in my book.

On Aug 19, 6:14 pm, Ben Schulz <[email protected]> wrote:
> > Obviously you gained type safety,
>
> > Isn't that kinda the point of a type system?  :-)
>
> I suppose, but for me it's more about why I should write down the
> types. If we asked Gilad Bracha, he'd probably say it's a bad idea
> because they restrain your thinking. Me, I say it's good because the
> compiler can verify that all messages sent are understood by their
> receivers. Structural unions would get me much farther in that
> direction and that's where I want to go. If I understand it correctly
> (and I can only hope in this case) I would not need to write down any
> types if higher-order unification was decidable. Wouldn't that be
> nice?
>
> With kind regards
> Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to