On 08/20/2010 07:21 AM, bearophile wrote:
Andrei Alexandrescu:
Sure. On the face of it, I think isNumeric is a silly function because
the effort expended on doing a good prediction is almost the same as
doing the actual conversion - so why not just try it.

The difference is that a well designed isNumeric doesn't need to use 
exceptions, this may make it faster (never forget that DMD exceptions are 
something like 12 times slower than Java-Sun ones). On the other hand I think 
isNumeric() is not used in situations where high performance is needed.

Good point.

I guess
    return collectException(to!real(input)) is null;
should be a fine replacement for isNumeric.

Do you mean that such ugly replacement is meant to be used in user code, or do 
you mean to replace the contents of the isNumeric() function with that code?

Put it in the body.


Andrei

Reply via email to