Fixing std.string
bearophile
bearophileHUGS at lycos.com
Fri Aug 20 05:21:25 PDT 2010
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.
> 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?
Bye,
bearophile
More information about the Digitalmars-d
mailing list