Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83138 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86988 invoked from network); 19 Feb 2015 01:23:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2015 01:23:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.21 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.21 mout.gmx.net Received: from [212.227.17.21] ([212.227.17.21:63393] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/A1-08593-BFA35E45 for ; Wed, 18 Feb 2015 20:23:08 -0500 Received: from [192.168.0.101] ([91.67.244.80]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MbOrg-1Y5d113APc-00InJ9; Thu, 19 Feb 2015 02:23:03 +0100 Message-ID: <54E53AFD.7060000@gmx.de> Date: Thu, 19 Feb 2015 02:23:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Anthony Ferrara CC: "internals@lists.php.net" References: <54E51B9E.1060201@gmx.de> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:xIKkh7+YjLgnRsJVybekwTOEcct+nQS4mJvt9V7wUyaVUGSeuDW ilQDAqGVfGkxvXrK4ScxBcBb8ilUV3h6JpO4mJwzVy1CMgrW/c+IV9AM2m2mFNdY9yZKC5s qq9uGtCcN6bChPhf2WV5VVaq6V9K3FrYIwjC8mZnYY5CU4uqTlwZu59jV+DigeYBgs22lPl PsK4IBxdU2nolhS494vxw== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: cmbecker69@gmx.de (Christoph Becker) Anthony, Anthony Ferrara wrote: > On Wed, Feb 18, 2015 at 6:09 PM, Christoph Becker wrote: > >> Have you considered the overflow behavior of ints resulting in a float? >> For instance, the following code would produce E_RECOVERABLE_ERROR, AIUI: >> >> > >> declare(strict_types=1); >> >> function foo(int a, int b) { >> bar(a * b); >> } >> >> function bar(int n) { >> } >> >> foo(10000000000, 10000000000); > > That is a very good point. We had discussed that a while ago, but it > hasn't come up in a while here. I've added a section in the RFC on it: > https://wiki.php.net/rfc/scalar_type_hints_v5#integer_overflow_to_float_behavior Thanks for adding a respective note to the RFC, because IMHO it's quite important to consider the behavior. Somehow I would like to have Scheme's numeric system, but that doesn't seem to fit well with type hinting (neither strict nor weak) -- at least not when it's about performance. > Basically, I don't see any sane alternative but to have it cause an > error at runtime. It's not precision loss, it's magnitude loss. > > The only other thing I can think of is to have the operators not > promote in strict mode, but that's even worse since now you're > clamping and not even giving the ability to detect it. > > I don't think in practice it will be a huge issue, but even if it > comes up, it'll at least error sanely... ACK. -- Christoph M. Becker