Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37461
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Andreas Leitgeb <avl@logic.at> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: underscore as keyword in Java 9 |
| Date | Sun, 24 Sep 2017 23:27:04 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 55 |
| Message-ID | <slrnosgfo9.ijn.avl@logic.at> (permalink) |
| References | <slrnoscj1i.ijn.avl@logic.at> <oq635r$alr$1@news.albasani.net> <oq704j$115r$1@gioia.aioe.org> <slrnosf5fq.ijn.avl@logic.at> <oq9bbe$lpo$1@gioia.aioe.org> |
| Reply-To | avl@logic.at |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Sun, 24 Sep 2017 23:27:04 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="8b4c51847cccbd9710fbe8ef734ece02"; logging-data="31245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JYkM1mnFuguqAUQAnThUW" |
| User-Agent | slrn/1.0.2 (Linux) |
| Cancel-Lock | sha1:vM/OOUvNLq/79Bv8nv79/ZAyEqg= |
| Xref | csiph.com comp.lang.java.programmer:37461 |
Show key headers only | View raw
Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 9/24/2017 7:25 AM, Andreas Leitgeb wrote:
>> [...] - A use they
>> sometimes already have - and this particular use is now being
>> forbidden just before likely being re-enabled.
> According to the link Java 8 gives a warning about the
> usage of _ as an identified[r?] because it may get a special
> meaning in a future Java version.
In Java up to (and including, despite the warning) 8, one can
have a method with (at most) one of the formal parameter names
called "_", as well as "catch (MyException _) ...", and it is
also (still) possible to actually see the value in "_" in the
respective block.
With Java 9, one can not use "_" as a param name or catch
identifier at all - regardless if used lateron or not.
In some future Java version "X" it *may* be, that one can once
again specify the keyword "_" in certain places, where currently
an identifier is required. It's probably going to mean that
whatever value would end up in that position is just dropped/
ignored/unretrievable.
Case 1:
final void foo(int _) { System.out.printf("%d%n", _); }
Case 2:
final void foo(int _) { System.out.printf("%d%n", 54); }
Both are legal in Java up to 8, illegal in 9, but only case 1
would remain illegal in that Java "X". Case 2 in Java "X" would
behave exactly the same as it behaved back in Java 7.
Anyone using "_" already now as if it were a black-hole identifier
(as in case 2) will have to change their code to use e.g. "_ignore"
instead, and only for Java "X" they will once again be able to
change it back to "_".
A less bumpy road would have been to only error on the *use* of
"_" as in case 1, while leaving case 2 legal until Java "X".
> That makes perfect sense to me at[s?] the old context
> may become illegal syntax in the future, so a good
> thing to get rid of that usage now before problems
> arise.
It would be, if only those usages were refused that would fail
with the new semantics.
But then again, the prognose about future meaning of "_" might be
entirely off, and "_" might get to mean something completely different
lateron - only then it would become clear, why "_" was illegalized
even for cases like case 2 above.
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