Method chaining for instance methods that return void

C

Chris Uppal

Dmytro said:
RFE: Method chaining for instance methods that return void
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373386

Ugh!

I think that all future requests for changes to the language should be
accompanied by an irrevocable guarantee from the requester that he, she, or
they, would do the actual work of updating /all/ the tools that would be
affected by the change. I.e. they would do the work of updating javac, they
would do the work of updating Eclipse, they would do the work of updating all
the hundreds of other tools out there which parse Java.

Beyond that, if you /are/ going to mess around with Java to support that idiom,
it would be /much/ better to support it properly. There is nothing to stop you
defining a syntax that means "send this message to the receiver of the previous
message". A parallel in Java of Smalltalk's "cascades" rather than the hacky,
restricted, and ugly "chaining" idiom.

-- chris
 
T

Thomas Hawtin

Dmytro said:
What do you think about this request for enhancement?

RFE: Method chaining for instance methods that return void
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373386

Many methods return values that programmers are unaware of. For
instance, remove methods may return a boolean to indicate something or
to return a previous value. That's going to make code using your
suggestion fail unexpectedly. Or in some case do things on an unexpected
object.

I don't like your chances of getting anything like this through. If
something were going to be introduced, I'd hope it'd go for a more
distinctive syntax, say:

builder ->
append("This "),
append(stuff),
append(".");

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top