Thread overview
[Issue 13522] Let's use '_' underscore as official ignore value
Sep 23, 2014
Ketmar Dark
Sep 23, 2014
Ketmar Dark
Sep 26, 2014
Ketmar Dark
Jul 08, 2015
Martin Nowak
Jun 07, 2019
Les De Ridder
Dec 17, 2022
Iain Buclaw
September 23, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #1 from bearophile_hugs@eml.cc ---
I've added my vote.

Once "_" means "ignored" (and it has become a name that can't be read), you can allow code like this where "_" is used more than once:

foreach (_; 0 .. 5)
    foreach (_; 0 .. 5) {}


foo((a, _, _) => a);


// some kind of tuple destructuring syntax:
@{a, b, _} = myTup;

Other potentially important usages of the "ignored" value are for pattern matching "ignored" wild-card.

--
September 23, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #2 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
one of my so-much-universally-hated ;-) patches does exactly this (but for '__' args — two underscores) for foreach args and lambda args (maybe function args too, i don't remember). it's such an amusement to see people requesting same things again and again.

as for 'foreach', this should be allowed too: `foreach (; 0..42)`. i'm using this for some time now and found it very handy.

--
September 23, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|ketmar@ketmar.no-ip.org     |

--
September 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #3 from hsteoh@quickfur.ath.cx ---
Would this cause interop problems with C programs that use GNU gettext, which conventionally defines '_' to be shorthand for 'gettext'?  (Not that I care about such an ugly C hack, but you never know, somebody might care.)

--
September 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #4 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
it shouldn't, but we can use two underscores for that. ids started with two underscores are reserved anyway.

--
October 25, 2014
https://issues.dlang.org/show_bug.cgi?id=13522

--- Comment #5 from bearophile_hugs@eml.cc ---
There are plans to totally disallow the use of "_" as variable name in Java:

http://openjdk.java.net/jeps/213

>In addition, using underscore ("_") as an identifier, which generates a warning as of Java SE 8, should be turned into an error in Java SE 9.<

--
July 08, 2015
https://issues.dlang.org/show_bug.cgi?id=13522

--- Comment #6 from Martin Nowak <code@dawg.eu> ---
There is precedence for this usage in python, haskell and scala.

--
June 07, 2019
https://issues.dlang.org/show_bug.cgi?id=13522

Les De Ridder <dlang@lesderid.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang@lesderid.net

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=13522

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--