Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84577 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8561 invoked from network); 11 Mar 2015 21:04:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2015 21:04:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.173 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.173 mail-lb0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:41629] helo=mail-lb0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/A1-32765-9FDA0055 for ; Wed, 11 Mar 2015 16:04:58 -0500 Received: by lbvp9 with SMTP id p9so11720769lbv.8 for ; Wed, 11 Mar 2015 14:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ErQN9VOoVQsNGbmqz0ADWBK8bhR72U7PCeGhbrIHHcg=; b=xwFPhCEPUAMxIbinx9rNqWQpzl13O9sO++MMQcwubZ9ScgOzLm4FfBZ2TKefQhP1Po VSo5SvOSt907Oq/xeAym1HxhF2/fsAIKmRZhqqS8T+eyvnSpYCPHoCxJ7kx9Vqq24lr2 +1VQr2kRbjo0ioMNBBARfbWDbD/ZT5pK4XFvZ8Z8+k2oQP3AMkW/tH3jCQxBkqv3K7cq 0y/8ZrK3wmlm1hba3HU/emICnbbzrv5Gt6/XxiH7MeaerbfC98m5GY7bGV4l94BOT9XN sc0HcX0FLqFD3EBqFCDFG5LmqB0ogbIDW785ZT0XSlad2Ky3wQ39n3A3/+fzuDwlVXsn +DlQ== MIME-Version: 1.0 X-Received: by 10.152.26.169 with SMTP id m9mr27190009lag.45.1426107894301; Wed, 11 Mar 2015 14:04:54 -0700 (PDT) Received: by 10.25.43.9 with HTTP; Wed, 11 Mar 2015 14:04:54 -0700 (PDT) In-Reply-To: References: <76c47c6fbd961958c10bc1a069377a34@mail.gmail.com> <2d48b241e682e59df6ab876b42663628@mail.gmail.com> Date: Wed, 11 Mar 2015 17:04:54 -0400 Message-ID: To: Zeev Suraski Cc: Derick Rethans , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] RE: [VOTE][RFC] Coercive Scalar Type Hints From: ircmaxell@gmail.com (Anthony Ferrara) Zeev, On Wed, Mar 11, 2015 at 4:50 PM, Zeev Suraski wrote: >> -----Original Message----- >> From: Derick Rethans [mailto:derick@php.net] >> Sent: Wednesday, March 11, 2015 10:37 PM >> To: Zeev Suraski >> Cc: Anthony Ferrara; internals@lists.php.net >> Subject: RE: [PHP-DEV] RE: [VOTE][RFC] Coercive Scalar Type Hints >> >> > You're right, sorry. Reverse it then: >> > function bar(int $x) >> > $foo = 1.0; >> > bar($foo); // will definitely fail in strict mode >> >> And it should fail, as logically it is the same as: >> >> $foo = 1.901 - 0.709 - 0.192; >> bar($foo); >> >> which is only 1, if you look at it with a small enough precision. > > I'm not sure what you're trying to say. The two pieces are indeed > identical from all points of view - static analysis, how it would behave > in strict type hinting, weak type hinting or coercive type hinting. I think Derick's point is more that: http://3v4l.org/b4S8d var_dump($foo); gives float(1) while it is != 1 (even loose). So debugging is weird, since it looks like it should work (hey, it says float(1), why isn't it passing for an int?). In strict mode, it's an error because it's a float. So it's not quite identical. Since logically it should work under your rules, but it doesn't work. And there's nothing to the user that implies or confirms that it shouldn't work. Anthony