Earlier quoted context omitted.
Actually for just that example you don't need any of it. new Thread(doStuff).Start();
nah, it would have to be new Thread(new ThreadStart(doStuff)).Start();
Java 8 lambda syntax decided - same as C# and Scala
21–30 of 81 posts
Sorry, but since C# 2.0 we could just write "new Thread(DoStruff)" or "SomeDelegate del = SomeMethod".
Re: Java 8 lambda syntax decided - same as C# and Scala
#22Re: Java 8 lambda syntax decided - same as C# and Scala
#23Re: Java 8 lambda syntax decided - same as C# and Scala
#24Re: Java 8 lambda syntax decided - same as C# and Scala
#25Nice to see pragmatism playing a role here. A big problem with Java has always been the "design by committee" nature of it where we end up with some theoretical best case that satisfies everyone's egos but turns out to utterly suck when used in practice.
From another point of view ... it's a shame we needed so many years to come up with "let's do it like C#".
Re: Java 8 lambda syntax decided - same as C# and Scala
#26Lambdas are a lot of fun on C#. new Thread( => { doStuff(); }).Start();
Big deal:
new Thread(new Runnable() { public void run() {doStuff();} }).start();Re: Java 8 lambda syntax decided - same as C# and Scala
#27Any details on variable capturing from outer scope? The same as C# (apparently capture all variables?)?
Re: Java 8 lambda syntax decided - same as C# and Scala
#28try { // for a really long time } finally { // made a decision }
try { /* thinking for a really long time */ } catch (TimeoutException ex) { /* copy from C# */ }Re: Java 8 lambda syntax decided - same as C# and Scala
#29Good. The lambda syntax in C# rocks and is a natural fit for Java considering the origin of C#.
Object Pascal?
Re: Java 8 lambda syntax decided - same as C# and Scala
#30try { // for a really long time } finally { // made a decision }
There's a JVM language out there that initially allowed try-statements without catch or finally clauses, e.g
try{
//for a short time only to decide
}
But one of its despots, five years after the language was first released, changed the syntax to make a catch or finally clause compulsory, e.g try{
//for a short time to decide
}finally{}
Because I had used these standalone try-statements a lot, I had to go thru all my code and add empty finally statements to them all.Scala, on the other hand, still allows standalone try-statements. And Scala and C# also have a better closure syntax than that language, and are more worthy to be copied by Java 8.