On 1/2/13 3:13 PM, Dmitry Olshansky wrote:
1/2/2013 7:24 PM, bearophile пишет:
monarch_dodra:

The rationale for this:
std.ascii: I think returning -1 as a magic number should help keep the
code faster and with less clutter than with exceptions.

For the ASCII version I have two use cases:
- Where I want to go fast&unsafe I just use "c - '0'".
- When I want more safety I'd like to use something as to!(), that
raises exceptions in case of errors.

A function that works on ASCII and returns -1 doesn't give me much more
than "c - '0'". So maybe exceptions are good in the ASCII case too.


Then we can maybe just drop this function? What's wrong with
if(std.ascii.isNumeric(a))
a -= '0';
else
enforce(false);

Unnecessary flow :o).

enforce(std.ascii.isNumeric(a));
a -= '0';


Andrei

Reply via email to