It's a borderline case, so removing the ability to call shoot() on a
Gun|Camera isn't that important, but I would argue that allowing it
means you're in structural typing land. I'd actually say that Allowing
shoot() on a Gun|Camera is more slack in the type system vs. not
allowing it.


On Aug 20, 11:26 am, Ben Schulz <[email protected]> wrote:
> On 19 Aug., 20:45, Reinier Zwitserloot <[email protected]> wrote:
>
>
>
>
>
> > 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.
>
> I don't think that argument works here. Yeah, idiots will be idiots,
> but it would take an extraordinary idiot to call shoot() on an object
> of type "Gun|Camera". Why do you insist on having more slack in your
> type system, just to exclude a tiny class of errors that noone is
> going to make anyways?
>
> 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