Thread overview
[Issue 15526] provide a way to ignore underscores for parsing integers
Jan 07, 2016
b2.temp@gmx.com
Jan 08, 2016
Vladimir Panteleev
Mar 21, 2020
Basile-z
Apr 21, 2021
Berni44
Dec 17, 2022
Iain Buclaw
January 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15526

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ignore underscores for      |provide a way to ignore
                   |parsing integers            |underscores for parsing
                   |                            |integers

--
January 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15526

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from b2.temp@gmx.com ---
(In reply to Steven Schveighoffer from comment #0)
> Liam McSherry created a PR to do this, but it was never fixed/accepted. Most of the discussion on this issue can be read in the PR comments here: https://github.com/D-Programming-Language/phobos/pull/3377

The `AllowUnderscores` parameter from the original PR should rather be a template parameter. If someone wants to allow underscores, this is because he strongly expects that the function will be used with underscores (which is not so common with int literals).

That's stupid to create an additional "runtime branch" for such an option, so maybe only as a template parameter.

--
January 07, 2016
https://issues.dlang.org/show_bug.cgi?id=15526

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
The consensus seems to have been that parse isn't the right place to put this at all, but rather create a new function that deals with parsing D integers (which can have underscores).

TBH, I don't think the runtime variable was a forethought, just a way to modify the function so that it behaved like the original for existing calls. Sure, a template parameter would work better, but also remember that precedent has things like radix being a runtime parameter.

In any case, having a separate function solves the backwards compatibility problem, and is as effective as a template parameter. But I don't know whether it's worth a whole new function for it.

Runtime parameter, template parameter, or new function name, this functionality should be somewhere in the library IMO.

--
January 08, 2016
https://issues.dlang.org/show_bug.cgi?id=15526

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
As I mentioned here:

https://github.com/D-Programming-Language/phobos/pull/3377#issuecomment-112791190

I think that by itself, the task of simply ignoring underscores is too trivial to deserve a separate Phobos function.

--
December 24, 2016
https://issues.dlang.org/show_bug.cgi?id=15526

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp
                 CC|                            |andrei@erdani.com

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=15526

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
April 21, 2021
https://issues.dlang.org/show_bug.cgi?id=15526

Berni44 <bugzilla@bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |apz28@hotmail.com

--- Comment #4 from Berni44 <bugzilla@bernis-buecher.de> ---
*** Issue 20568 has been marked as a duplicate of this issue. ***

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
October 29
https://issues.dlang.org/show_bug.cgi?id=15526

Chris Piker <matrix-magma-cloak@duck.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matrix-magma-cloak@duck.com

--- Comment #5 from Chris Piker <matrix-magma-cloak@duck.com> ---
Just wanted to bring attention to this issue, since it hasn't been mentioned in a while and I ran into it yesterday.  The lack of symmetry between the calls:

double d  = to!double("1_000_000");
int i     = to!int("1_000_000");

was surprising.  I presume this wasn't the original intent, since it's good to avoid surprises in API.

--