parse and skipWhite
monarch_dodra
monarchdodra at gmail.com
Thu Oct 4 01:48:41 PDT 2012
A couple weeks ago, an issue came up regarding parse's behavior
in regards to skipping leading ws.
http://d.puremagic.com/issues/show_bug.cgi?id=8729
https://github.com/D-Programming-Language/phobos/pull/817
https://github.com/D-Programming-Language/phobos/pull/828
The gist of the conversations is that the current behavior "do
not skip leading whitespaces" was not completely enforced
(because parse!double did skip'em) this meant 2 things:
1) parse!double needed to be "fixed" to behave like the others.
(new pull 833)
2) parse's behavior was put into question:
2).1) Parse should be changed to skip leading ws.
2).2) Parse should keep NOT skipping leading ws
The conversation concluded towards 2.2: Do not skip WS.
Another proposal was made though, to introduce a "skipWhite"
function that would take and return by reference, and also work
on ranges, two things "std.String.stripLeft" does not do. This
would allow this syntaxes:
string ss = ...
double d = ss.skipWhite().parse!double();
while(!ss.skipWhite().empty)
ss.parse!double().writeln();
I proposed this in (currently closed) pr 827
https://github.com/D-Programming-Language/phobos/pull/827
MY ISSUE THAT I WOULD LIKE DISCUSSED HERE IS:
The introduction of "skipWhite" would make "permanent" turn to
the "do not skip ws" behavior: If this function exists, then
surely, it is because parse does not skip ws.
If we don't introduce it though, it means that if it turns out we
DO want to make parse skip ws, then we won't have that useless
function bothering us.
So yeah, what are your thought, do you want to see "skipWhite" in
std.conv? Or do you think it would be better to just do without
it? Keep in mind, it *is* convenient though! :D
More information about the Digitalmars-d
mailing list