PROPOSAL: Return 'this'

Artur Biesiadowski abies at
Wed Mar 25 15:42:43 PDT 2009

I think that you are putting two separate proposals here:

1) Having 'silent' exit from method and parameterless return equivalent 
to 'return this' if method return type is non-void

2) Introducing kind of auto-covariant return type, which resolves to 
given class and accepts only 'this' returns

I don't particularly like point 1 - it will save some typing, but has 
certain kind of magic I would prefer to keep out of java. Point 2 is 
nice for builders, unfortunately it cannot be used for anything else 
other than chain calls - for example, clone method could not be written 
using this functionality (as you could write return new A() in A class 
and not redefine it in B).

I don't understand Compatibility forward: Only jars. I don't see a way 
to have such code verified in existing versions of java.

Artur Biesiadowski

More information about the coin-dev mailing list