Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7822
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: new Java lambda syntax |
| Date | 2011-09-11 14:08 -0700 |
| Organization | albasani.net |
| Message-ID | <j4j7vm$hgl$1@news.albasani.net> (permalink) |
| References | (2 earlier) <llbsj8-b59.ln1@news.simpsonst.f2s.com> <alpine.DEB.2.00.1109111255530.13018@urchin.earth.li> <9j3vj8-aqe.ln1@news.simpsonst.f2s.com> <j4item$o69$1@news.albasani.net> <tsdvj8-vbg.ln1@news.simpsonst.f2s.com> |
On 9/11/2011 12:14 PM, Steven Simpson wrote:
> On 11/09/11 19:08, BGB wrote:
>> I would have also liked to see lexical variable capture.
>> FFS, I added this (along with closures) to a C compiler before, can't
>> be too hard
>
> At this stage, I don't think the issue is how, but whether/when to
> permit it.
>
> All suggestions for how seem to come down to boxing:
>
> * arrays of length 1
> * hidden local classes
> * AtomicInteger, etc
>
> (If there were any others, I didn't understand them.)
>
> The options for when/whether have been:
>
> * never
> * always
> * when a local is tagged with @Shared, public or similar
> * when the SAM parameter is tagged with @Callback, @Block or similar
>
> They've gone for 'never' because it's sufficient to meet their primary
> goals of supporting concurrent APIs, especially on collections, and they
> want to encourage good concurrent practices. They can still look at the
> other options later - it would be harder to withdraw an advanced
> feature, having discovered it was a bad idea.
>
fair enough, just I guess this makes it a bit different from several
other languages with closures (such as JS).
>> having spent more of my time using languages with much nicer
>> first-class functions (yes, I will include C here, as well as
>> JavaScript and similar...), having to have extra syntax (both to
>> declare and use these types) is IMO lame.
>>
>> in all cases, one would type "obj(args)".
>>
>> idiomatic for Java or not, the more compact declarations and
>> invocations are more what people who use most other languages are
>> likely to expect (and ideally the compiler can be smart enough to
>> figure out what "obj(args)" with a SAM means).
>
> Lambda declarations are already quite compact, with type inference
> helping in most cases.
>
> new Thread(() -> { doSomething(); }).start(); // Runnable implied
>
> For invocations, having to type obj.run() instead of obj() is hardly
> onerous. Plus, invocations will be much rarer than lambda declarations.
> Also note that the invocation site is unaware of whether the object is a
> lambda.
>
yes, ok.
however... whether or not it is a lambda could be made a side issue:
Runnable obj;
...
obj();
could be made to "just work" (with either a lambda, or with an interface).
it may not matter much for things like traditional callbacks/..., but it
could make more of a difference if people want something like assignable
methods.
being able to type: "obj.someAssignableMethod();" would be a little
nicer looking than "obj.someAssignableMethod.run();".
even if, yes, this is all basically just syntax sugar.
(among other things, like getter/setter properties, ...).
also, misc:
in my own language, the above thread example could be written:
async { doSomething(); }
( I had considered making the braces optional, but at the moment this
poses more subtle issues. in the above context, async serves as a
thread-creation keyword. )
not that I think syntax sugar is a huge issue though, as (after all) I
still do much of my programming in C (peoples' value-judgements against
C aside...).
or such...
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
new Java lambda syntax markspace <-@.> - 2011-09-08 13:19 -0700
Re: new Java lambda syntax Roedy Green <see_website@mindprod.com.invalid> - 2011-09-08 15:18 -0700
Re: new Java lambda syntax Arne Vajhøj <arne@vajhoej.dk> - 2011-09-08 18:27 -0400
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-08 15:40 -0700
Re: new Java lambda syntax Arne Vajhøj <arne@vajhoej.dk> - 2011-09-08 19:27 -0400
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-08 16:29 -0700
Re: new Java lambda syntax Arne Vajhøj <arne@vajhoej.dk> - 2011-09-08 19:48 -0400
Re: new Java lambda syntax Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-09-08 17:56 -0700
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-08 22:23 -0700
Re: new Java lambda syntax "Nasser M. Abbasi" <nma@12000.org> - 2011-09-08 16:41 -0700
Re: new Java lambda syntax Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-08 20:50 -0500
Re: new Java lambda syntax bugbear <bugbear@trim_papermule.co.uk_trim> - 2011-09-09 09:33 +0100
Re: new Java lambda syntax Tom Anderson <twic@urchin.earth.li> - 2011-09-10 14:48 +0100
Re: new Java lambda syntax Steven Simpson <ss@domain.invalid> - 2011-09-10 16:17 +0100
Re: new Java lambda syntax Tom Anderson <twic@urchin.earth.li> - 2011-09-11 13:06 +0100
Re: new Java lambda syntax Steven Simpson <ss@domain.invalid> - 2011-09-11 17:18 +0100
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-11 11:08 -0700
Re: new Java lambda syntax Steven Simpson <ss@domain.invalid> - 2011-09-11 20:14 +0100
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-11 14:08 -0700
Re: new Java lambda syntax Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-11 17:07 -0500
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-11 16:18 -0700
Re: new Java lambda syntax Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-13 02:00 +0200
Re: new Java lambda syntax Arne Vajhøj <arne@vajhoej.dk> - 2011-09-12 20:59 -0400
Re: new Java lambda syntax Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-12 21:24 -0500
Re: new Java lambda syntax Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-13 21:04 +0200
Re: new Java lambda syntax Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-13 15:22 -0500
Re: new Java lambda syntax Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-13 23:25 +0200
Re: new Java lambda syntax Tom Anderson <twic@urchin.earth.li> - 2011-09-13 21:29 +0100
Re: new Java lambda syntax Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-13 23:26 +0200
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-13 20:25 -0400
Re: new Java lambda syntax Tom Anderson <twic@urchin.earth.li> - 2011-09-15 21:58 +0100
Re: new Java lambda syntax Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-13 21:36 -0500
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-13 22:49 -0400
Re: new Java lambda syntax "supercalifragilisticexpialadiamaticonormalizeringelimatisticantations" <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-14 02:49 -0400
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-14 03:01 -0400
Re: new Java lambda syntax "winkleMeister" <..00@00.00.00.1> - 2011-09-14 09:59 +0000
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-15 10:16 -0400
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-14 06:40 -0400
Re: new Java lambda syntax supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-09-15 10:16 -0400
Re: new Java lambda syntax lightworker <etts@0n.org.null> - 2011-09-16 01:57 +0000
Re: new Java lambda syntax thoolen <th00len@th0lenbot.thorium> - 2011-09-15 22:41 -0400
Re: new Java lambda syntax Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-14 06:29 -0300
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-14 07:40 -0700
Re: new Java lambda syntax Lew <lewbloch@gmail.com> - 2011-09-14 08:01 -0700
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-14 14:50 -0700
Re: new Java lambda syntax Lew <lewbloch@gmail.com> - 2011-09-14 18:02 -0700
Re: new Java lambda syntax BGB <cr88192@hotmail.com> - 2011-09-14 21:08 -0700
csiph-web