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


Groups > comp.lang.java.programmer > #37452 > unrolled thread

underscore as keyword in Java 9

Started byAndreas Leitgeb <avl@logic.at>
First post2017-09-23 11:58 +0000
Last post2017-09-28 11:41 +0200
Articles 9 on this page of 29 — 8 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#37496

FromSebastian <nowhere@nirvana.org>
Date2017-09-27 20:26 +0200
Message-ID<oqgqg6$dst$1@news.albasani.net>
In reply to#37476
Am 26.09.2017 um 02:24 schrieb Arne Vajhøj:
> On 9/25/2017 5:30 PM, Silvio wrote:
>> I do like what Scala also does with the _ identifier (it also uses it
>> as throw-out identifier). In Scala
>>
>> _ + 1
>>
>> is shorthand for
>>
>> x_1001 => x_1001 + 1
>>
>> and
>>
>> _.toLowerCase
>>
>> is shorthand for
>>
>> x_1002 => x_1002.toLowerCase
>>
>> and Scala goes even further. It defines
>>
>> _ * _
>>
>> to be a shorthand for
>>
>> (x_1003,x_1004) => x_1003 * x_1004
>>
>> This allows for expressions like
>>
>> x.filter(_.length > 1).map(_.toInt).reduce(_ + _)
>>
>> which is far more concise and readable than
>>
>> x.filter(a => a.length > 1).map(b => b.toInt).reduce((c,d) => c + d)
>
> It is definitely shorter.
>
> I am not as convinced about more readable.
>
> Arne
  especially when one can use method references instead.
-- Sebastian

[toc] | [prev] | [next] | [standalone]


#37499

FromSilvio <silvio@internet.com>
Date2017-09-27 23:10 +0200
Message-ID<59cc13c6$0$2170$e4fe514c@newszilla.xs4all.nl>
In reply to#37496
On 27-09-17 20:26, Sebastian wrote:
> Am 26.09.2017 um 02:24 schrieb Arne Vajhøj:
>   especially when one can use method references instead.
> -- Sebastian

Method references are an ugly hack. Just like SAMs. They where bending 
over backwards...

[toc] | [prev] | [next] | [standalone]


#37478

FromAndreas Leitgeb <avl@logic.at>
Date2017-09-26 08:29 +0000
Message-ID<slrnosk3tt.ijn.avl@logic.at>
In reply to#37471
Silvio <silvio@internet.com> wrote:
> I personally think _ as a throw-out identifier is not very useful. If 
> you do not want a name then change the grammar to allow leaving it out 
> at the first place, like C++ did.

Good point.

> I do like what Scala also does with the _ identifier (it also uses it as 
> throw-out identifier). In Scala [...]

That's likely what Brian Goetz referred to in his mail from back in 2013
(see OP for link to mail) :

" [...], except that we are certainly NOT going to do Scala's "wunderbar".

[toc] | [prev] | [next] | [standalone]


#37494

FromSilvio <silvio@internet.com>
Date2017-09-27 19:08 +0200
Message-ID<59cbdb0f$0$20500$e4fe514c@newszilla.xs4all.nl>
In reply to#37478
On 26-09-17 10:29, Andreas Leitgeb wrote:
> Silvio <silvio@internet.com> wrote:
>> I personally think _ as a throw-out identifier is not very useful. If
>> you do not want a name then change the grammar to allow leaving it out
>> at the first place, like C++ did.
> 
> Good point.
> 
>> I do like what Scala also does with the _ identifier (it also uses it as
>> throw-out identifier). In Scala [...]
> 
> That's likely what Brian Goetz referred to in his mail from back in 2013
> (see OP for link to mail) :
> 
> " [...], except that we are certainly NOT going to do Scala's "wunderbar".
> 

That is probably what he meant. So that is just one more thing we 
disagree on. Not that he would care...

Silvio

[toc] | [prev] | [next] | [standalone]


#37497

FromSebastian <nowhere@nirvana.org>
Date2017-09-27 21:46 +0200
Message-ID<oqgv76$3id$1@news.albasani.net>
In reply to#37478
Am 26.09.2017 um 10:29 schrieb Andreas Leitgeb:
> Silvio <silvio@internet.com> wrote:
>> I personally think _ as a throw-out identifier is not very useful. If
>> you do not want a name then change the grammar to allow leaving it out
>> at the first place, like C++ did.
>
> Good point.
>
>> I do like what Scala also does with the _ identifier (it also uses it as
>> throw-out identifier). In Scala [...]
>
> That's likely what Brian Goetz referred to in his mail from back in 2013
> (see OP for link to mail) :
>
> " [...], except that we are certainly NOT going to do Scala's "wunderbar".
>
I find underscore as "don't care" parameter very useful. Especially in 
unit testing, I noften find myself having to write trivial things, like 
the tautology (java.util.function.Predicate) "always -> true". I'd like 
to be rid of having to invent useless variable names and write "_ -> 
true" instead. And so on for unused lambda params in general.

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#37491

FromEric Douglas <e.d.programmer@gmail.com>
Date2017-09-27 06:53 -0700
Message-ID<febf1d6b-caae-4daa-b162-80997e0faa15@googlegroups.com>
In reply to#37452
On Saturday, September 23, 2017 at 7:58:52 AM UTC-4, Andreas Leitgeb wrote:
> When googling for underscore keyword I found a mail by Brian Goetz, where
> he hinted for a future use of the "_" keyword:
> 
>   http://mail.openjdk.java.net/pipermail/lambda-dev/2013-July/010670.html
> 
> " However, things it might be used for include things like "I don't want
> " to give this variable a name" (such as catch parameters that are never
> " used.)
> 
> Now, some people might already have used that identifier in exactly such
> circumstances, namely for variable names that need to be there
> syntactically, but are not intended to be used.
> 
> It strikes me odd, that Java would first forbid them generally, only to 
> later essentially encourage that particular use again.
> 
> Maybe, if that was the intention already 4 years ago, they should only 
> have made uses of "_" as values (lvalue or rvalue) illegal.
> 
> Comments?  Maybe there have risen newer intentions for different uses
> in the meantime?

Not sure when this started, just happened to check today and noticed Oracle officially has Java 9 on their download page (http://www.oracle.com/technetwork/java/javase/downloads/index.html).

[toc] | [prev] | [next] | [standalone]


#37492

FromAndreas Leitgeb <avl@logic.at>
Date2017-09-27 15:59 +0000
Message-ID<slrnosnimk.ijn.avl@logic.at>
In reply to#37491
Eric Douglas <e.d.programmer@gmail.com> wrote:
> Not sure when this started, just happened to check today
> and noticed Oracle officially has Java 9 on their download
> page
> (http://www.oracle.com/technetwork/java/javase/downloads/index.html).

In earlier days, Roedy Green used to post info about new Java (update)
releases. This time Stefan Ram posted the trigger that made me skim
over the new features.

[toc] | [prev] | [next] | [standalone]


#37501

FromArne Vajhøj <arne@vajhoej.dk>
Date2017-09-27 19:18 -0400
Message-ID<oqhbk0$4fk$1@gioia.aioe.org>
In reply to#37492
On 9/27/2017 11:59 AM, Andreas Leitgeb wrote:
> Eric Douglas <e.d.programmer@gmail.com> wrote:
>> Not sure when this started, just happened to check today
>> and noticed Oracle officially has Java 9 on their download
>> page
>> (http://www.oracle.com/technetwork/java/javase/downloads/index.html).
> 
> In earlier days, Roedy Green used to post info about new Java (update)
> releases. This time Stefan Ram posted the trigger that made me skim
> over the new features.

I actually wrote a little piece about the new features.

More or less the same as the official one and all the
other summaries.

But my examples are different.

:-)

http://www.vajhoej.dk/arne/articles/java19.html

Arne

[toc] | [prev] | [next] | [standalone]


#37504

FromDaniele Futtorovic <da.futt.news@laposte.net>
Date2017-09-28 11:41 +0200
Message-ID<oqig5e$vep$1@dont-email.me>
In reply to#37501
On 2017-09-28 01:18, Arne Vajhøj wrote:
> http://www.vajhoej.dk/arne/articles/java19.html

Nice writeup. Thanks.

-- 
DF.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.java.programmer


csiph-web