Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100270 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12916 invoked from network); 21 Aug 2017 15:04:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2017 15:04:20 -0000 X-Host-Fingerprint: 2.24.106.64 unknown Received: from [2.24.106.64] ([2.24.106.64:7305] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/B1-34801-376FA995 for ; Mon, 21 Aug 2017 11:04:19 -0400 Message-ID: <17.B1.34801.376FA995@pb1.pair.com> To: internals@lists.php.net References: <11BCF7F8-4AEE-43FE-9D26-7D64C54EA382@gmail.com> Date: Mon, 21 Aug 2017 16:04:16 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 2.24.106.64 Subject: Re: [PHP-DEV] Re: [Request][Discussion] Double value as array key improvement From: ajf@ajf.me (Andrea Faulds) Hi everyone, Nikita Popov wrote: > > Sounds good to me. Something you might want to consider is to also throw a > warning if the floating point number is not an exact integer. For example > allow a silent cast of 42.0 to 42, but throw a warning if 42.5 is used as > an index (or worse, 42.999999999, in which case it likely isn't doing what > the programmer thinks it's doing). I wonder about whether this is a good idea. I've previously suggested something like this myself, but at the present time, I'd be more concerned about consistent behaviour. We do silent casts from floats to integers in other places in PHP. Array indices aren't that special. Moreover, this implicit truncation behaviour is useful in some cases. -- Andrea Faulds https://ajf.me/