Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7746

Re: new Java lambda syntax

From BGB <cr88192@hotmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: new Java lambda syntax
Date 2011-09-08 22:23 -0700
Organization albasani.net
Message-ID <j4c7tf$qjp$1@news.albasani.net> (permalink)
References (1 earlier) <phfi67pevhtnqoq57v10fvm3t83qjd69br@4ax.com> <j4bg8q$11c$1@news.albasani.net> <4e694f5f$0$311$14726298@news.sunsite.dk> <j4bj5c$659$1@news.albasani.net> <x_2dnR1tDZ-v-fTTnZ2dnUVZ_judnZ2d@posted.palinacquisition>

Show all headers | View raw


On 9/8/2011 5:56 PM, Peter Duniho wrote:
> On 9/8/11 4:29 PM, BGB wrote:
>> [...]
>>> As a curiosum then C# also allows:
>>>
>>> delegate(int x) { return x+1; }
>>>
>>
>> this was their older syntax, before they added "=>", why? who knows...
>
> The "=>" syntax was introduced as part of a broader application, the
> more general lambda expression feature. In certain contexts, a C# lambda
> expression becomes an anonymous method, but in other contexts, it
> becomes a specific kind of expression type.
>
> The "delegate" syntax predates the generalized lambda expression and is
> usable _only_ for anonymous methods. In that context, it makes a lot of
> sense, because anonymous methods can be referenced only via a delegate
> instance, so reusing the keyword to express that gives some continuity.
>

fair enough...


>> delegate would work, except it is a question if the Java people would
>> have wanted to add this keyword either...
>
> I haven't seen anything about the syntax for a new function pointer type
> in Java to use with a lambda. Maybe that's what the message from Goetz
> means when he writes "…have not yet come to a decision on method
> reference syntax". But it's possible that _some_ new keyword will yet
> need to be added.
>

I wouldn't know, I don't subscribe to that list, so I have no idea what 
is going on there.


> Whether that's "delegate" or something else, who knows? (Well, okay…I'll
> bet someone does. I just haven't been keeping up on the issue, so _I_
> don't know).
>

"int (*foo)(int x);"
ok, maybe not...


in my own language, I use the 'typedef' keyword in a manner similar to 
C#'s use of the 'delegate' keyword (and my language uses 'delegate' for 
something almost entirely different).


but, possible could be something like:

typedef int FooMethodType(int x);
...
FooMethodType assignableMethod;
...
assignableMethod = (int x)=>x+1;
or:
assignableMethod = FooMethodType=>x+1;


in my own syntax, it would be more like:
typedef function FooMethodType(x);
...
var assignableMethod:FooMethodType;
...
assignableMethod = fun(x) x+1;

although, possibly nice:
assignableMethod = FooMethodType=>x+1;


where, in my language, typedef is technically a modifier (it is not a 
syntactic form, and also has no effect on parsing in any way, unlike in 
C or C++).


now, what do I use 'delegate' for?
for inter-object delegation (technically, it is a scoping feature).

basically, it makes object variables "transparent", so that the 
fields/methods/... located within the referenced objects may be accessed 
as if they were part of the current scope (basically, sort of like 
"static import" but with object instances and variables, and it may 
apply recursively).

attempting to access a variable or call a method may forward the request 
to the object in question (with some edge-case semantics WRT instance 
methods, but I will not really go into this). note that it still 
respects 'private' and similar.


technically, in this language, packages are themselves implemented as 
objects (and imports are internally implemented using variables linking 
to said package-objects).

implicitly, "this" may be considered as itself analogous to a delegate 
variable, but my language allows implementing more variables with 
similar behavior (and also allows building a "toplevel" out of a 
patchwork of linked object instances).


or such...

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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