PROPOSAL: Return 'this'

Marek Kozieł develop4lasu at gmail.com
Wed Mar 25 16:24:38 PDT 2009


W dniu 26 marca 2009 00:04 użytkownik Neal Gafter <neal at gafter.com> napisał:
> I would expect these methods to be erased to void-returning methods,
> and the duplication of the receiver to occur on the caller's side in
> the generated code.

I know that this is some solution, but proposal in this form can be
extended to work with (backward) covariant return types in future:

     static class A {
             public this test() {   }
     }
     static class B extends A {
             public this A test() {  }
     }

>So there's no need for any kind of special
> auto-covariant type or anything.  You'd need extra a rule that a
> method declared to return this can only be overridden by (and can only
> override) a method similarly declared to return this.  You need to say
> how such methods are recorded in class files (an additional classfile
> Attribute on the method?).  How are they treated by reflection?  How
> do they appear in the javadoc API?  How should they appear in javadoc?
>  How do they appear in the program model API for annotation
> processing?
>
>

Everything would be same as:
     static class A { public A test() {  return this; } }
     static class B extends A { public B test() {  return this; } }

But I'm opened to any suggestions.

-- 
Pozdrowionka. / Regards.
Lasu aka Marek Kozieł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list