Implicit 'this' return for void methods

Victor Polischuk victor2 at ukr.net
Fri Mar 28 04:57:08 UTC 2014


Ulf,

I think that point leading style is something which can be easily mistreat. If we complicate the example:

   String mySub = myVeryLongNamedString.substring(.indexOf("C"),.indexOf("Q"));

to something like:

   String mySub = myVeryLongNamedString.concat("BLAH").substring(.indexOf("C"),.indexOf("Q"));

it is not 100% clear which object will be applied for ".indexOf" method, either (myVeryLongNamedString) or (myVeryLongNamedString + "BLAH"). Also I believe that the need of executing the instance methods to get parameter values for its another method is an API issue. Helpers like StringUtils from commons-lang resolve this particular case and many similar. Moreover, the helper correctly takes care of the situation when Q meets before C which means you would not use the feature like in above (even if it is implemented).

However, I totally agree that the "chaining" feature should be done as a compiler time AST modification to allow using legacy APIs without recompilation and keep byte-code, existing APIs and various conventions untouched.

---
Regards,
Victor Polischuk


 --- Original message ---
 From: "Ulf Zibis" <ulf.zibis at cosoco.de>
 Date: 28 March 2014, 00:30:45
  


> 
> Am 27.03.2014 23:05, schrieb Eirik Lygre:
> > With this suggested change, the only behavior that will change is that some code which used to not 
> > compile will start compiling, with a reasonable result. No code that used to compile will change.
> 
> Yes, this is one of the great advantages of this "simple" _language_ change proposal !
> 
> -Ulf
> 
> 



More information about the core-libs-dev mailing list