Re: About to!int

2012-01-31 Thread Jonathan M Davis
On Tuesday, January 31, 2012 08:05:37 bearophile wrote: > Jonathan M Davis: > > I don't see std.conv.to changing. > > We'll see. As far as I recall, you're the only person to ever bring this up (though you have brought it up before). In general, I think that programmers are fine with how to!int

Re: About to!int

2012-01-31 Thread bearophile
Jonathan M Davis: > and it's the sort of thing that > he's likely to consider bikeshedding at this point - He isn't the only Phobos developer. It's a change able to improve my usage of conversions, so it's not a neutral change (as I think 'bikeshedding' implies). > particularly since he's >

Re: About to!int

2012-01-31 Thread bearophile
Zardoz: > Try parse!int(" 12\n"); > http://www.d-programming-language.org/phobos/std_conv.html#parse It doesn't work, because it accepts a ref string. So you have to write: string s = " 12\n"; int n = parse!int(s); But it doesn't work still, it chokes on the first space, so you have to remove i

Re: About to!int

2012-01-31 Thread Jonathan M Davis
On Monday, January 30, 2012 21:01:38 bearophile wrote: > In Python int() and float() convert a string into a number even if it contains some whitespace before and after the number: > >>> s = " 12\n" > >>> int(s) > > 12 > > >>> float(s) > > 12.0 > > > In D to!int(" 12\n") gives a run-time er

Re: About to!int

2012-01-30 Thread Zardoz
On Mon, 30 Jan 2012 21:01:38 -0500, bearophile wrote: > > In D to!int(" 12\n") gives a run-time error. So time ago I have weakly > asked Andrei to change to!int, to let it ignore leading and trailing > whitespace, but he has ignored my request. > > A leading newline comes often from input std