digitalmars.D.learn - std.conv length=0
- Derek Parnell <derek nomail.afraid.org> Apr 10 2007
- Bill Baxter <dnewsgroup billbaxter.com> Apr 10 2007
Currently, the functions in std.conv throw an exception if the input string
is empty. What is the rationale for this?
I find myself writing shims like ...
int makeInt(char[] d)
{
if (d.length == 0) return toInt("0");
return toInt(d);
}
Is there anyone here that relies on an empty string throwing a conversion
error?
Also, I see that there is no link back to the DWiki/DocComments in the
std.conv docs.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Justice for David Hicks!"
10/04/2007 5:27:01 PM
Apr 10 2007
Derek Parnell wrote:Currently, the functions in std.conv throw an exception if the input string is empty. What is the rationale for this? I find myself writing shims like ... int makeInt(char[] d) { if (d.length == 0) return toInt("0"); return toInt(d); } Is there anyone here that relies on an empty string throwing a conversion error?
Well the empty string is not a number, so it seems clear that there are times (perhaps the majority even) when you would want to treat that as an ill-formatted number error. Just like "fred" isn't a number. I'm assuming that throws an exception too. --bb
Apr 10 2007








Bill Baxter <dnewsgroup billbaxter.com>