Daniel Keep 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
I only had a short look, is it the NaN known from floating point types
generalized to all types?
:D
-- Daniel