Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93744 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80547 invoked from network); 3 Jun 2016 12:31:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jun 2016 12:31:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.107 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.107 blu004-omc2s32.hotmail.com Received: from [65.55.111.107] ([65.55.111.107:52526] helo=BLU004-OMC2S32.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/E2-56709-38871575 for ; Fri, 03 Jun 2016 08:31:00 -0400 Received: from BLU436-SMTP97 ([65.55.111.72]) by BLU004-OMC2S32.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Fri, 3 Jun 2016 05:30:57 -0700 X-TMN: [aq1bZ4FSiz6LiDWTfYVhX9YA7QGcoa+F] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_688391FF-BD23-458F-BB8E-2457884F96E4" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <652fdc5a-a164-2054-ed61-305a2b72330a@gmail.com> Date: Fri, 3 Jun 2016 14:30:52 +0200 CC: internals@lists.php.net References: <0A.C5.62101.1C860575@pb1.pair.com> <68b821ac-d71f-4be5-8dca-ae94db332630@gmail.com> <20160603101659.D466A1A81FC5@dd1730.kasserver.com> <6d448fd8-8fda-d795-accb-6b96cd128ccd@gmail.com> <652fdc5a-a164-2054-ed61-305a2b72330a@gmail.com> To: Rowan Collins X-Mailer: Apple Mail (2.2070.6) X-OriginalArrivalTime: 03 Jun 2016 12:30:54.0438 (UTC) FILETIME=[C5A76860:01D1BD93] Subject: Re: [PHP-DEV] [RFC] [PRE-VOTE] Union types From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_688391FF-BD23-458F-BB8E-2457884F96E4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="windows-1252" > Am 3.6.2016 um 14:18 schrieb Rowan Collins : >=20 > On 03/06/2016 12:59, Bob Weinand wrote: >>> function l(string | float $x) { echo gettype($x); } >>> l("1.5a"); // I would expect string, but float would succeed if = attempted >>=20 >> Exact matches *ALWAYS* match without coercion. >=20 > Gah, I keep making that mistake in my examples. I did say I was = struggling to get my head around things! ;) >=20 > I'm still missing an explanation of exactly where you derived the = current proposed rules from, though. The RFC just states "these rules = are not an invention of this proposal", but goes on to say "applies PHP = casting rules in a sane way", which implies some decisions were involved = in drawing up these rules. >=20 > I think you may be right that the rules are as simple as they can be, = and I don't want to waste too much of your time, but a basic summary of = the reasoning used would be much appreciated. >=20 > Regards, > --=20 > Rowan Collins > [IMSoP] The *weak casting* rules (i.e. what gets converted how and what can be = converted to the other type) are not an invention of the proposal. The proposal however defines the specific order. I=92ve added a reasoning why not left-to-right now. As this seemed to be = asked multiple times. Also, the specific reasoning why I propose that specific order the rules = are in: > Otherwise PHP's casting rules are applied in an order to be as = lossless as possible. That=92s really the only motivation behind that. Bob --Apple-Mail=_688391FF-BD23-458F-BB8E-2457884F96E4--