Live data from Hacker News

Java 8 lambda syntax decided - same as C# and Scala

mail.openjdk.java.net

11–20 of 81 posts

Re: Java 8 lambda syntax decided - same as C# and Scala

#12
Excellent to have this finally resolved. I'm sad to not see something a little closer to the ruby block syntax like in some of the early proposals, though. Special syntax for lambdas as the last argument to a function lets you write very readable code for a host of useful cases.

Re: Java 8 lambda syntax decided - same as C# and Scala

#13

Lambdas are a lot of fun on C#. new Thread( => { doStuff(); }).Start();

According to the grammar int the OP, you need ()'s, no? new Thread(() => { doStuff(); }).Start(); Or can they be elided in C# or Scala?

The empty () are required in Scala. Don't know about C#.

Re: Java 8 lambda syntax decided - same as C# and Scala

#14

Lambdas are a lot of fun on C#. new Thread( => { doStuff(); }).Start();

According to the grammar int the OP, you need ()'s, no? new Thread(() => { doStuff(); }).Start(); Or can they be elided in C# or Scala?

Actually for just that example you don't need any of it. new Thread(doStuff).Start();

Re: Java 8 lambda syntax decided - same as C# and Scala

#15
post #14

Earlier quoted context omitted.

According to the grammar int the OP, you need ()'s, no? new Thread(() => { doStuff(); }).Start(); Or can they be elided in C# or Scala?

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();

Re: Java 8 lambda syntax decided - same as C# and Scala

#17

Earlier quoted context omitted.

According to the grammar int the OP, you need ()'s, no? new Thread(() => { doStuff(); }).Start(); Or can they be elided in C# or Scala?

The empty () are required in Scala. Don't know about C#.

yes, they are in C# as well.

Re: Java 8 lambda syntax decided - same as C# and Scala

#18
post #8

Earlier quoted context omitted.

How is this a mistake ?

Erm, its not?. Shawndumas was just pointing out that a decision was finally made. They were grappling over the syntax for over two three years. Now they will just need to grapple over with what kind of scoping that Java's lambdas will have.

I think stating it that way trivializes the amount of work that _has_ gone into lambdas. There's been a lot of other, more fundamental things discussed over that 2-3 year period about their implementation; way more than syntax.
Post reply on HN