Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70975 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89811 invoked from network); 3 Jan 2014 01:51:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2014 01:51:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:53230] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/21-15275-FA716C25 for ; Thu, 02 Jan 2014 20:51:43 -0500 Received: by mail-wi0-f174.google.com with SMTP id z2so8301wiv.7 for ; Thu, 02 Jan 2014 17:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=zkt98AlZM9dmo2DcPBFKOyNnA/0+PSlhUmPEzbeOo5Q=; b=HnpacaIoz7J1FGY3WM//Q5x7np58YDf47nYa/u43XFXR/EaPgcb5PSm3mXCE+d2lMQ 0Li0HH3BO61UVVghbvONZlVAKxKi83B8NTZ3EbsLeA4zN7nTrcrJDfI4w9ugADSWRi2B miT4NiRgNRzKs13maR8XfxeOW7TifgJdC6q+w5IdS6UD+RLdOYK7sW6PcOHXjthwGPaO FOujmzo1UNrJ0kgYULnQIq/UmCywlnlUxAEB/qJe/Yj9zoYfYtSgeOY1LTt/8cJhXfEd f2xfBn4566CpwKFdfQYA+0/AQejxzsZgsSGld/FeuMc8PAT0SJrzSCAVNggqdd8q46oC 4vxw== X-Received: by 10.180.126.4 with SMTP id mu4mr9174wib.36.1388713900752; Thu, 02 Jan 2014 17:51:40 -0800 (PST) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginm.net. [81.101.201.26]) by mx.google.com with ESMTPSA id gz5sm17673wib.10.2014.01.02.17.51.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 17:51:39 -0800 (PST) Message-ID: <52C617A8.3060800@gmail.com> Date: Fri, 03 Jan 2014 01:51:36 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <001801cf07e9$a07af1e0$e170d5a0$@tutteli.ch> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] NAN and INF cast to int From: rowan.collins@gmail.com (Rowan Collins) On 02/01/2014 19:55, Yasuo Ohgaki wrote: > I've added this to the RFC as an issue. > https://wiki.php.net/rfc/comparison_inconsistency The introduction on that RFC links to a rather confused bug report about min() and max() behaviour with mixed types. [1] The actual behaviour for comparisons between types is documented on the manual page for Comparison Operators [2], and is a largely separate issue to the behaviour of the actual conversions - it is not a question of how the values behave when converted, but which conversions are applied. The current documentation for min() and max() is thoroughly unhelpful, implying special cases which don't exist, and missing behaviours that do. I submitted a patch on edit.php.net with revised examples and a clearer explanation and link to that page, but there seems to have been a glitch somewhere: the patches showed in the "Contributions are ready" reports for a while [3] but then seemingly disappeared without trace - I asked if anyone knew where they were, but nobody answered [4]. The non-commutativity of conversions does make this all very confusing (sorting arrays containing mixed types is actually unpredictable in some cases, and again the documentation is rather lacking), but is inevitable since such conversions may be "lossy" - e.g. (bool)42, (bool)43, and (bool)44 cannot possibly be distinct values. The only other option in many cases is simply to throw an error when such a comparison is attempted, and reject the entire computation. Links: [1] https://bugs.php.net/bug.php?id=53104 [2] http://php.net/manual/en/language.operators.comparison.php [3] http://news.php.net/php.doc/969384748 [4] http://news.php.net/php.doc/969384775 Regards, -- Rowan Collins [IMSoP]