|
|
|
|
|
by cbo
5226 days ago
|
|
I don't know a lick of iOS or Obj-C, but this line is absolutely true: > The biggest boon to closures, for "regular" programmers, is the dramatic simplification of async code. Consider the way it's currently done in Java: listener.addCallback(new AsyncCallback<ReturnType>(Parameters ..) {
public void onSuccess(ReturnType returned) {
System.out.println("Successfully returned!");
}
public void onFailure(Throwable thrown) {
System.out.println("Unsuccessfully returned!");
}
});
This is unbelievably ugly, and yet this is about as easy as it gets in Java. In order to make asynchronous callbacks "easier" you have to instantiate an anonymous class with very precisely named methods.It's not only wasteful, but the potential for error is huge. Closures could make this much, much simpler. |
|