Re: Change IntlChar::getNumericValue() to return something less horrible when the char is not numeric?

From: Date: Thu, 09 Jul 2015 07:09:56 +0000
Subject: Re: Change IntlChar::getNumericValue() to return something less horrible when the char is not numeric?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-87083@lists.php.net to get a copy of this message
Hi On Wed, Jul 8, 2015 at 9:45 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote: >> I would change the function to return NULL instead; what do you think? > > While the exact value of U_NO_NUMERIC_VALUE looks weird, nobody is going > to use it directly, you'd be using U_NO_NUMERIC_VALUE. Comparing to it > doesn't look wrong. So changing that to null doesn't seem to improve > much, just introduce incompatibility with ICU. personally, I think null (or even false) is better because it's of a different type (and falsy) and thus more likely to get noticed that something is wrong. In PHP, you're used to checking for null or false. Having to deal with values that look like they are within valid ranges and which also validate to something true-ish is needlessly difficult and unexpected. The unicode standard apparently wants to use NaN, so ICU is already deviating from the standard. Philip

« previous php.internals (#87083) next »