Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #20976
| From | Steven Simpson <ss@domain.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? |
| Date | 2013-01-05 11:21 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jvelr9-ck2.ln1@s.simpson148.btinternet.com> (permalink) |
| References | (5 earlier) <odmer9-onl.ln1@s.simpson148.btinternet.com> <0680c1e0-16cb-4791-8a5f-95a3ff2bcba8@googlegroups.com> <fa166a9f-b0ed-4eba-9789-97ef2f67923a@googlegroups.com> <mcujr9-dfs.ln1@s.simpson148.btinternet.com> <6f020a38-4566-4739-8ec7-a85d02a68d86@googlegroups.com> |
On 05/01/13 09:50, Saxo wrote:
> Am Freitag, 4. Januar 2013 22:32:38 UTC+1 schrieb Steven Simpson:
>> On 03/01/13 14:45, Saxo wrote:
>>
>> I'm still interested in seeing an example that you would normally write
>> with free variables, demonstrating that lambdas are inadequate for the
>> things you'd like to do.
> Groovy:
>
> def list = [1, 2, 3]
> def sum = 0
> list.each { sum += it }
> println(sum)
>
> Kotlin:
>
> val list = arrayListOf(1, 2, 3)
> var sum = 0;
> list.forEach { i -> sum += i }
> println(sum)
>
> Scala:
>
> val list = List(1, 2, 3)
> var sum = 0
> list.foreach(sum += _)
> println(sum)
Sorry, but aren't these the same example that you originally gave, just
in different languages? I'm looking for different examples, perhaps
expressed in a Java-like language with the features you were hoping for.
> Apparently, JDK8 lambdas can be assigned to a Runnable.
...if they take no arguments, returning nothing, and throw no checked
exceptions. Java lambdas don't have their own special function types,
and have to be associated with a SAM type as soon as they are
expressed. Type inference is expected to make this implicit in most cases.
--
ss at comp dot lancs dot ac dot uk
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? jeti789@web.de - 2013-01-02 07:08 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? jeti789@web.de - 2013-01-02 07:52 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-02 17:33 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-02 11:31 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Lew <lewbloch@gmail.com> - 2013-01-02 12:52 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-01-02 20:58 -0400
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Lew <lewbloch@gmail.com> - 2013-01-02 17:40 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-01-03 20:43 -0400
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-02 23:44 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Patricia Shanahan <pats@acm.org> - 2013-01-03 07:57 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Lew <lewbloch@gmail.com> - 2013-01-03 13:22 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Patricia Shanahan <pats@acm.org> - 2013-01-03 16:14 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-02 21:46 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Lew <lewbloch@gmail.com> - 2013-01-02 17:35 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-03 02:13 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-03 06:45 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-04 21:32 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2013-01-04 14:38 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-04 23:45 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2013-01-04 17:24 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-05 13:20 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-05 01:50 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-05 11:21 +0000
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Saxo <jeti789@web.de> - 2013-01-05 04:27 -0800
Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Steven Simpson <ss@domain.invalid> - 2013-01-05 12:58 +0000
csiph-web