You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stefan Bodewig <bo...@apache.org> on 2014/04/03 10:27:11 UTC

Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

On 2014-04-03, <eb...@apache.org> wrote:

> Don't use '_' as an identifier to avoid a compiler warning with Java 8

why is Java8 complaining?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Bear Giles <bg...@coyotesong.com>.
I'm bummed. One of my interview torture questions was whether this compiles.

class _ {
  static _ _ ;
  _() {
  }
  _(_ _) {
  }
}


On Thu, Apr 3, 2014 at 6:44 AM, Stefan Bodewig <bo...@apache.org> wrote:

> On 2014-04-03, Emmanuel Bourg wrote:
>
> >
> http://openjdk.5641.n7.nabble.com/Warning-about-single-underscore-identifier-td145974.html
>
> They are deprecating the use of "_" for method argument names so that
> one day I may be able to use it for the exact same purpose I've done so
> for :-)
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Stefan Bodewig <bo...@apache.org>.
On 2014-04-03, Emmanuel Bourg wrote:

> http://openjdk.5641.n7.nabble.com/Warning-about-single-underscore-identifier-td145974.html

They are deprecating the use of "_" for method argument names so that
one day I may be able to use it for the exact same purpose I've done so
for :-)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Emmanuel Bourg <eb...@apache.org>.
I found this explanation from Brian Goetz:

http://openjdk.5641.n7.nabble.com/Warning-about-single-underscore-identifier-td145974.html

"Yes, we are "reclaiming" the syntactic real estate of "_" from the
space of identifiers for use in future language features.  However,
because there are existing programs that might use it, it is a warning
for identifiers that occur in existing syntactic positions for 8, and an
error for lambda formals (since there is no existing code with lambdas.)

Your suspicion is mostly right, except that we are certainly NOT going
to do Scala's "wunderbar".  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.)"

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Stefan Bodewig <bo...@apache.org>.
On 2014-04-03, Benedikt Ritter wrote:

> 2014-04-03 12:05 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

>> On 2014-04-03, Benedikt Ritter wrote:

>>> I didn't now that '_' is a valid identifier at all.

>> That's a different point. :-)

>> _ is used as an identifier in many funtional languages to mean "any
>> argument, I don't care for it anyway"

> How about changing the name to "ignored" then?

yes, that or "unused" would be my second choice.  But no need to change
anything anymore, I can easily live with Emmanuel's change, I was just
curious.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Benedikt Ritter <br...@apache.org>.
2014-04-03 12:05 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

> On 2014-04-03, Benedikt Ritter wrote:
>
> > I didn't now that '_' is a valid identifier at all.
>
> That's a different point. :-)
>
> _ is used as an identifier in many funtional languages to mean "any
> argument, I don't care for it anyway" when you need to have an argument
> for a certain contract but won't use it.  This is exactly what I used it
> for in the code Emmanuel changed.
>

How about changing the name to "ignored" then?

Benedikt


>
> In other contexts _ means "anything" when used for pattern matching.
> You'll see that in Scala or F# or other ML inspired languages as well as
> in Haskell.
>
> When used with the correct settings the C# compiler will complain about
> method arguments that you don't use and if you prefix the argument name
> by a _ (or just use _ if there is only one such argument) it will no
> longer complain.  I think this is where I finally picked up the habit.
>
> So I'm suprised Java8's compiler complains, I don't think it has done so
> before or I would have noticed.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Stefan Bodewig <bo...@apache.org>.
On 2014-04-03, Benedikt Ritter wrote:

> I didn't now that '_' is a valid identifier at all.

That's a different point. :-)

_ is used as an identifier in many funtional languages to mean "any
argument, I don't care for it anyway" when you need to have an argument
for a certain contract but won't use it.  This is exactly what I used it
for in the code Emmanuel changed.

In other contexts _ means "anything" when used for pattern matching.
You'll see that in Scala or F# or other ML inspired languages as well as
in Haskell.

When used with the correct settings the C# compiler will complain about
method arguments that you don't use and if you prefix the argument name
by a _ (or just use _ if there is only one such argument) it will no
longer complain.  I think this is where I finally picked up the habit.

So I'm suprised Java8's compiler complains, I don't think it has done so
before or I would have noticed.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Benedikt Ritter <br...@apache.org>.
2014-04-03 10:27 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

> On 2014-04-03, <eb...@apache.org> wrote:
>
> > Don't use '_' as an identifier to avoid a compiler warning with Java 8
>
> why is Java8 complaining?
>

I didn't now that '_' is a valid identifier at all.


>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Stefan Bodewig <bo...@apache.org>.
On 2014-04-03, Emmanuel Bourg wrote:

> Le 03/04/2014 10:27, Stefan Bodewig a écrit :

>> why is Java8 complaining?

> I don't know, it says '_' is deprecated and may become illegal in the
> future. I guess '_' may be used for a new language feature.

OK, thanks, didn't know that.  I've by noe found a place in the updated
Java tutorial where it says variable names starting with an underscore
are discouraged.  What a pitty.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1584206 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 03/04/2014 10:27, Stefan Bodewig a écrit :

> why is Java8 complaining?

I don't know, it says '_' is deprecated and may become illegal in the
future. I guess '_' may be used for a new language feature.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org