nothrow function to tell if a string can be converted to a number?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Sep 11 20:37:22 PDT 2013


On Wed, Sep 11, 2013 at 08:15:26PM -0700, Timothee Cour wrote:
> anyways, isNumeric sounds buggy, isn't it?

Yeah, I'd file a bug. I can't see how "i" can possibly be numeric. I
thought the compiler rejected that anyway?


> On Wed, Sep 11, 2013 at 4:03 PM, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> 
> > On Wed, Sep 11, 2013 at 02:10:32PM -0700, Timothee Cour wrote:
> > > actually that doesn't work:
> > >
> > > assert(!isNumeric(`j`)); //ok
> > > assert(!isNumeric(`i`)); //fails ; i is treated as a complex number but
> > > that's not good behavior as we can't write auto a=i;
> >
> > Yikes!
> >
> > This makes me *extremely* glad built-in complex numbers are
> > deprecated... can you imagine the mess that would result if you had a
> > loop counter named 'i' and the loop body contains expressions involving
> > 'i' and complex literals involving (the other) 'i'?
> >
> > *shudder*
> >
> >
> > T
> >
> > --
> > GEEK = Gatherer of Extremely Enlightening Knowledge
> >

-- 
Help a man when he is in trouble and he will remember you when he is in trouble again.


More information about the Digitalmars-d-learn mailing list