Re: inheritance bug?

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
>I think it should be the same as Java.  Methods can't be overridden to 
>be more private.
>  
>
Yes, that's fine with me.

I had in mind a more shady business: some obscure case, where the 
bahviour of the JVM (or javac) had to be changed from one version of the 
JDK to another (not recently). I don't have the details in mind, but it 
might be something like:

package p1;

public class A {
  public void foo() throws Exception {}
}

class B extends A {
  public void foo() {}
}

public class C extends B {
}

package p2;

public class D extends C {
  public void foo() throws Exception {}
}

B overrides foo "covariantly" by removing the exception list, so any 
overriding of foo should also not throw any exception, otherwise there 
would be unsafety. The thing is that B is not public, so D is not 
supposed to know about it, so neither about that foo implementation. I'm 
not sure what is the answer in Java at the moment.

Reducing the exception list is equivalent, typing-wise, to specilizing 
the return type.

Of course, this Java example is further complicated by the fact that a 
public method is "contained" inside a non-public class. In Nice you 
could speak of the implementation of foo for B, even though B is not 
public (which only means you cannot call B's default constructor, and 
probably use B in a type expression in p2).

So maybe there will be no problem in Nice.

>I still don't understand why the original hello() method is 
>overloading, not overriding.  Is nice-void different than java-void?  
>Is there a way to specifically declare the return type for the method 
>as java-void (for readability/documentation purposes)?  I'll update the 
>wiki with more examples of using Nice from Java, but I need to know 
>what I'm talking about!
>  
>
Ignoring since you since found out, but weren't you using Java from Nice 
in this example?

Daniel



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.