Method Handle reference?

260 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

Mark Derricutt

lukematon,
19.12.2011 klo 19.23.5319.12.2011
vastaanottaja xtend...@googlegroups.com
Hey all,

Given that Xtend uses Class::methodName to invoke a static method on a class, and now that JDK8 will be using Class::methodName to denote a MethodHandler, has anyone thought about how Xtend should handle this?

Is it invisenged that Class::methodName is the MethodHandle (static or instance), and Class::methodName(args) is a static invocation?  Seems a bit confusing.

(For reference clojure uses Class/methodName for static invocations)

Mark

Sven Efftinge

lukematon,
20.12.2011 klo 3.04.4520.12.2011
vastaanottaja xtend...@googlegroups.com
> Given that Xtend uses Class::methodName to invoke a static method on a class, and now that JDK8 will be using Class::methodName to denote a
> MethodHandler, has anyone thought about how Xtend should handle this?

The currently used syntax in Lambda is just a proposal. I have hope they switch to '#'.
Brian (Goetz) said that the current proposal is just an idea, and he indicated that they put out such decisions from revision to revision to get the communities feedback. So if enough people claim it's an odd choice (not because of Xtend but because in JavaDoc it's a '#') it might be helpful feedback :-)

We can't change this in Xtend since it would break existing code.
We have plan's for the same feature but using a '#'.

So ideally we all tell Brian & Co that '#' is a great syntax ;-)

Here's the list :
http://mail.openjdk.java.net/mailman/listinfo/lambda-dev

>
> Is it invisenged that Class::methodName is the MethodHandle (static or instance), and Class::methodName(args) is a static invocation? Seems a bit confusing.

Yes, indeed. Also it's ambiguous.

Sven

ngan.v...@gmail.com

lukematon,
9.11.2014 klo 8.25.019.11.2014
vastaanottaja xtend...@googlegroups.com
When will this method reference feature be supported? I don't mind whether "::" or "#" is used.

Vincent

Sven Efftinge

lukematon,
10.11.2014 klo 1.56.5910.11.2014
vastaanottaja xtend...@googlegroups.com
It is currently not scheduled, since we consider other stuff (e.g. IntelliJ support) more important.
With Xtend’s syntax a lambda that delegates to a method is already super short, so this feature doesn’t help in terms of conciseness.

e.g.

Java Lambda : (person)=>person.getName()
Java Method Ref : Person::getName
Xtend Lambda : [name]

It doesn’t get any shorter.

Performance wise I am not sure whether and how much faster a method reference is compared to a lambda, but my guess is, that a lambda like the above 
should be compilable to the equivalent bytecode. Maybe Sebastian can shed some light on it, as he recently did some performance measurements for Java 8 lambdas.

btw. We do plan to have a special compile target for Java 8 in the next version, where Xtend compiles to java 8 lambdas.

Cheers,
Sven


On 09 Nov 2014, at 14:25, ngan.v...@gmail.com wrote:

When will this method reference feature be supported? I don't mind whether "::" or "#" is used.

Vincent







--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xtend-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Trummer

lukematon,
5.11.2015 klo 12.36.065.11.2015
vastaanottaja Xtend Programming Language
is there already a new way to do this in xtend 2.8.4?

i.e. what is the xtend equivalent to this:
stream().mapToDouble(TestCls::getDblValue().sum()
what I came up with is this:
stream.mapToDouble(it | dblValue).sum

maybe there's a better way?

Sebastian Zarnekow

lukematon,
6.11.2015 klo 3.00.026.11.2015
vastaanottaja Xtend Programming Language
HI Martin,

the more idiomatic syntax would be

stream.mapToDouble [ dblValue ].sum

e.g. with squared brackets to implement the lambda. There are plans to support method references, but since the notation with a 'plain' lambda is already very concise for many cases, method references do not have the highest priority right now.

Best,
Sebastian

Martin Trummer

lukematon,
6.11.2015 klo 3.40.166.11.2015
vastaanottaja xtend...@googlegroups.com
hi,

>stream.mapToDouble [ dblValue ].sum
this syntax is better anyway!

But since I just started, xtend this was not clear to me.
Maybe it would be good to mention that somewhere in the docs for people who come from Java 8.

Mit freundlichen Grüssen/Kind  regards,
 Martin Trummer
______________________________
DI (FH) Martin Trummer
Mobile: +43 676 700 47 81
skype:ds.martin.trummer
mailto:martin....@dewesoft.com

DEWESoft GmbH
Grazerstrasse 7
A-8062 Kumberg
Austria / Europe
Tel.: +43 3132 2252
Fax: +43 3132 2252
UID-Nr.: ATU 654 93414
FB-Nr.:  078/4236-21
www.dewesoft.com
______________________________

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and delete this e-mail.
Any unauthorized copying, disclosure or distribution of the material in this e-mail is prohibited.

--
You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/uya3Zmvrteo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xtend-lang+...@googlegroups.com.

Sebastian Zarnekow

lukematon,
6.11.2015 klo 3.44.276.11.2015
vastaanottaja xtend...@googlegroups.com
Hi Martin,
this part of the docs may contain some more information about the lambda syntax in Xtend:

https://www.eclipse.org/xtend/documentation/203_xtend_expressions.html#lambdas

Best,
Sebastian

Martin Trummer

lukematon,
6.11.2015 klo 3.51.456.11.2015
vastaanottaja xtend...@googlegroups.com
hi,

yes, but that was obviously not clear enough to me (as a newbie)

I think it would make sense to mention this in the "Java Interoperability" chapter:

and also a note in the "Static Access" chapter:
because in my case, I did search the doc for the double column operator. thus I ended up at the static access and learned that this is different
--> so here would be the perfect place to describe what the xtend equivalent of the the Java double colon operator is (i.e. linkt ot the lambda syntax.




Mit freundlichen Grüssen/Kind  regards,
 Martin Trummer
______________________________
DI (FH) Martin Trummer
Mobile: +43 676 700 47 81
skype:ds.martin.trummer
mailto:martin....@dewesoft.com

DEWESoft GmbH
Grazerstrasse 7
A-8062 Kumberg
Austria / Europe
Tel.: +43 3132 2252
Fax: +43 3132 2252
UID-Nr.: ATU 654 93414
FB-Nr.:  078/4236-21
www.dewesoft.com
______________________________

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and delete this e-mail.
Any unauthorized copying, disclosure or distribution of the material in this e-mail is prohibited.

Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä