PROPOSAL: Return 'this'

Marek Kozieł develop4lasu at gmail.com
Wed Mar 25 16:03:31 PDT 2009


2009/3/25 Artur Biesiadowski <abies at adres.pl>:
> 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
>

Yes. but thanks to this proposition is extremely safe and simple (no
null-s = NPE/ not other object).

> 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).

This is the price of simplicity.

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

Simple flag would solve the problem, do not forget that this solution
is same level with void (already handled).

>
> Regards,
> Artur Biesiadowski
>

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

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list