Implicit 'this' return for void methods
Eirik Lygre
eirik.lygre at gmail.com
Fri Mar 28 08:46:22 UTC 2014
On Fri, Mar 28, 2014 at 5:57 AM, Victor Polischuk <victor2 at ukr.net> wrote:
> 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)..
I think the concept of "expressions starting with the period" is not going
to happen, because the code is not easy enough to read (ref "Reading is
more important than writing" in
http://www.oracle.com/technetwork/articles/javase/jpl-proposals-140227.html),
so I'm not going there. It may or may not be reasonable from a technical
point of view, but my gut feeling says that it won't pass the process, so
it is better to focus on the core feature.
The core feature, to me, is "syntactic sugar to allow chaining of void
methods". This feature should be easy to specify, understand, read and
write:
* myObject.setSomething(...).setSomething(...).setSomething(...)
This feature will make the use of a large body of existing libraries much
easier (all things JavaBeans), at a low cost.
More information about the core-libs-dev
mailing list