Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37458
| From | j4n bur53 <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: underscore as keyword in Java 9 |
| Date | 2017-09-24 17:30 +0200 |
| Organization | albasani.net |
| Message-ID | <oq8j1q$19s$1@news.albasani.net> (permalink) |
| References | <slrnoscj1i.ijn.avl@logic.at> <oq635r$alr$1@news.albasani.net> <oq704j$115r$1@gioia.aioe.org> <slrnosf5fq.ijn.avl@logic.at> |
Yeah, somehow it would work if a "_" is an ordinary variable, for example in: _, y, _ := coord(p) Then "_" could be an integer (or what ever number is used in coord). Then we would have: "_" gets assigned by a value (the x from coord) y gets assigne by a value (the y from coord) "_" gets assigned, overridden, by a value (the z from coord) But now there is a problem, what if we have such a code: _, _, e = person(z) And if person returns for example (name:String, age:integer, employer:String). Then Andreas Leitgrebs re-enablement is just phantasie, since in a type safe language, this simple translation with the same variable "_" doesn't work: "_" gets assigned by a value (the name from person) "_" gets assigned, overridden, by a value (the age from coord) e gets assigned by a value (the employer from person) The two "_" are in type conflict. But Garbage collection and everything in Java needs types. So there is no re-enablement whatever, this would be a new feature. A requirement would be that "_" is really really short lived, and quickly losses its type and can acquire another type... > Arne Vajhøj <arne@vajhoej.dk> wrote: >> On 9/23/2017 12:46 PM, j4n bur53 wrote: >>> As long as Java doesn't have multi-returns, there >>> will be not many use cases. For multi returns, if >>> they were in the Java language, it could be offered >>> as in the Go Programming Language: >>> /* fetching the y coordinate of a 3D point */ >>> _, y, _ := coord(p) >> I suspect that Java will get that in version 10 or 11. >> Reason: C# got it in version 7 (and Java and C# tend >> to steal ideas from each other). >> Syntax like: >> (int v1,int v2) = M(); > > These speculations are entirely orthogonal to the point that "_" > is taken away from the realm of identifiers, but might in future > be used syntactically like throw-away identifiers - A use they > sometimes already have - and this particular use is now being > forbidden just before likely being re-enabled. >
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-23 11:58 +0000
Re: underscore as keyword in Java 9 j4n bur53 <janburse@fastmail.fm> - 2017-09-23 18:46 +0200
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-23 21:01 -0400
Re: underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-24 11:25 +0000
Re: underscore as keyword in Java 9 j4n bur53 <janburse@fastmail.fm> - 2017-09-24 17:30 +0200
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-24 18:24 -0400
Re: underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-24 23:27 +0000
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-24 21:10 -0400
Re: underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-25 13:30 +0000
Re: underscore as keyword in Java 9 Eric Douglas <e.d.programmer@gmail.com> - 2017-09-25 08:07 -0700
Re: underscore as keyword in Java 9 lewbloch@gmail.com - 2017-09-25 13:21 -0700
Re: underscore as keyword in Java 9 Silvio <silvio@internet.com> - 2017-09-25 23:30 +0200
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-25 20:24 -0400
Re: underscore as keyword in Java 9 j4n bur53 <janburse@fastmail.fm> - 2017-09-26 13:37 +0200
Re: underscore as keyword in Java 9 Silvio <silvio@internet.com> - 2017-09-27 19:05 +0200
Re: underscore as keyword in Java 9 Eric Douglas <e.d.programmer@gmail.com> - 2017-09-27 10:25 -0700
Re: underscore as keyword in Java 9 Silvio <silvio@internet.com> - 2017-09-27 23:02 +0200
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-27 20:02 -0400
Re: underscore as keyword in Java 9 Eric Douglas <e.d.programmer@gmail.com> - 2017-09-28 05:11 -0700
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-28 20:42 -0400
Re: underscore as keyword in Java 9 Sebastian <nowhere@nirvana.org> - 2017-09-27 20:26 +0200
Re: underscore as keyword in Java 9 Silvio <silvio@internet.com> - 2017-09-27 23:10 +0200
Re: underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-26 08:29 +0000
Re: underscore as keyword in Java 9 Silvio <silvio@internet.com> - 2017-09-27 19:08 +0200
Re: underscore as keyword in Java 9 Sebastian <nowhere@nirvana.org> - 2017-09-27 21:46 +0200
Re: underscore as keyword in Java 9 Eric Douglas <e.d.programmer@gmail.com> - 2017-09-27 06:53 -0700
Re: underscore as keyword in Java 9 Andreas Leitgeb <avl@logic.at> - 2017-09-27 15:59 +0000
Re: underscore as keyword in Java 9 Arne Vajhøj <arne@vajhoej.dk> - 2017-09-27 19:18 -0400
Re: underscore as keyword in Java 9 Daniele Futtorovic <da.futt.news@laposte.net> - 2017-09-28 11:41 +0200
csiph-web