Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83095 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91223 invoked from network); 18 Feb 2015 17:28:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 17:28:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:5688] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/00-25021-4ABC4E45 for ; Wed, 18 Feb 2015 12:28:05 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 4569C4B027D; Wed, 18 Feb 2015 18:27:42 +0100 (CET) Reply-To: To: "'Zeev Suraski'" , =?utf-8?Q?'P=C3=A1draic_Brady'?= Cc: "'PHP internals'" References: <54E3E27B.2010903@lerdorf.com> <2f99c47df51fa6c73131032ec50fade0@mail.gmail.com> In-Reply-To: Date: Wed, 18 Feb 2015 18:27:59 +0100 Message-ID: <034f01d04ba0$3df39ad0$b9dad070$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQKz6wpj8b81mnwJq1LfxWbU4ZJyQgGjcksIAbrU1N8Bn0wufQGLyLi6AmixSwcCoM80egIWjKzSmsIVw2A= Content-Language: fr X-Antivirus: avast! (VPS 150218-0, 18/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Scalar Type Hints v0.4 From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) > De : Zeev Suraski [mailto:zeev@zend.com] > > That means that "42" can coerce into int, and "42.2" can coerce into = float, > and int can coerce into float - but not vice versa. I was wondering : should we systematically reject float to int, or = should we accept it when range fits and fractional part is null ? Shorter : can 7.0 be considered as an integer ? Example : if we completely disable float to int : function foo(int $arg) {} foo(ceil()); <- fails while ceil result is always integer foo(abs()); <- the same On one side, it depends on value, which is not so good. On the other = side, we must consider, the number behind the representation *is* an = integer. And PHP math functions too often return integers as floats = (mostly for a question of range) Anyway, one more use case against strict mode, as the examples above, = while considered intuitively and technically correct, would fail. And = there several more. Would the solution be to create another exception = :) ? > A somewhat sticky points is coercion into boolean. We need to figure = this > one out, and hopefully we can come up with something most people can > agree to. As I already said, with such a C-like syntax, we probably cannot disable = (int -> bool), so the same for 'integer string' to bool, as it is = natural to give this the same rule as native int. Not sure for float but = I would say OK too, as C habits prevail IMO. > Another open question would be coercion of float/int into string. = This > particular point might be good for a secondary vote, as I imagine = people > from both camps won't see this particular conversion as a major = deal-breaker > for them (could be wrong). I don't see the point here. It creates data but there's no ambiguity in = the way to represent it as a string. I think bidirectional 'numeric = string' <-> int/float conversion is a concept easier to understand and = remember. Regards Fran=C3=A7ois