[Issue 3609] isNumeric causes a stack overlfow with mutable arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 11 21:43:26 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3609



--- Comment #3 from David Simcha <dsimcha at yahoo.com> 2009-12-11 21:43:25 PST ---
(In reply to comment #2)
> IMHO it's kind of silly to define isNumeric. It does about the same amount of
> work as to, but doesn't give you the actual number. I suggest we just yank it.

The only problem I see with this is that then you're using exception handling
as flow control if your goal was just to validate something.  Then again, this
might not be a big deal because:

1.  Why would you be validating something as being numeric if you have no
intention of converting it to a number?

2.  One reason why using exceptions as flow control is considered bad is
performance.  Not too many people try to convert strings to numbers inside
performance critical code.

3.  The other reason why exceptions as flow control is considered bad is that
it's unstructured flow control, kind of like goto.  However, in this case I
don't think that applies.

real foo;
try {
    foo = to!real(someString);
} catch(ConvError) {
    // yada yada yada
}

Seems pretty clear and readable to me.

IMHO taking it out is probably a good move but I think we should think twice
and allow others to comment b/c it does have the downside of encouraging using
exceptions as flow control.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list