On Mon, 23 Mar 2009 16:32:03 +0300, Daniel Keep <[email protected]>
wrote:
bearophile wrote:
grauzone:
From your site:<
I don't own LiveJournal :-) That's just my blog, my site is elsewhere.
Using exceptions in a string->int conversion routine is really
horrible and incredibly stupid.<
I agree that it's not nice looking, but in Python that's the standard
idiom.
In D I do the same thing when I want to know if a string contains an
integer or float, with toInt/toFloat, how can I do it with no
exceptions?
Python3 also removes the find() method of strings, and leaves only the
index() method, that is like find(), but raise ValueError when the
substring is not found. So you are forced to use exceptions here too.
So far in D I have used exceptions to control flow only once, in this
library module (original code idea by Witold Baryluk, modified):
http://www.fantascienza.net/leonardo/so/dlibs/generators.html
Bye,
bearophile
Andrei already solved this problem; I'm just waiting for its
implementation to be possible in D...
http://www.nwcpp.org/Meetings/2006/05.html
:D
-- Daniel
Yay, The Power of None! That's what I was referring to when proposed nullable
types:
int? value1 = atoi("0"); // 0
int? value2 = atoi("#!$"); // null