Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14618 invoked from network); 2 Jun 2016 18:45:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2016 18:45:47 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.166 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.166 blu004-omc4s27.hotmail.com Received: from [65.55.111.166] ([65.55.111.166:59546] helo=BLU004-OMC4S27.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/58-62101-8DE70575 for ; Thu, 02 Jun 2016 14:45:47 -0400 Received: from BLU436-SMTP58 ([65.55.111.137]) by BLU004-OMC4S27.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Thu, 2 Jun 2016 11:45:42 -0700 X-TMN: [jhK93DOhqPVMDyauhzj5vdQgRsnPcWnF] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) In-Reply-To: <64cafa7a-2426-6c54-8e48-f060ab1edaf9@fleshgrinder.com> Date: Thu, 2 Jun 2016 20:45:35 +0200 CC: Andrea Faulds Content-Transfer-Encoding: quoted-printable References: <0A.C5.62101.1C860575@pb1.pair.com> <64cafa7a-2426-6c54-8e48-f060ab1edaf9@fleshgrinder.com> To: PHP internals X-Mailer: Apple Mail (2.3112) X-OriginalArrivalTime: 02 Jun 2016 18:45:40.0098 (UTC) FILETIME=[F5BD1620:01D1BCFE] Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: bobwei9@hotmail.com (Bob Weinand) > Am 02.06.2016 um 19:52 schrieb Fleshgrinder : >=20 > On 6/2/2016 7:37 PM, Bob Weinand wrote: >> Hey, >>=20 >> I think this is more of a presentation problem. >> As you say, there's not much a better way to do that. >>=20 >> It's basically our weak casting rules, just applied to the most = lossless type available. >> It's out weak casting rules which are so complex; the RFCs = combination is not particularly complex. >> It needs to cover everything, but it's particularly important for the = trivial cases to be handled here. Would be quite WTF if you could not = pass a float to something accepting int (as one of its types). >>=20 >> I'd welcome every suggestion to make the rules look less scary, = because they actually aren't. >>=20 >> Bob >>=20 >=20 > Don't you think this matrix would be a better presentation and = simpler? >=20 > |--------|--------|--------|--------| > | type | #1 | #2 | #3 | > |--------|--------|--------|--------| > | bool | string | int | | > | int | string | float | bool | > | float | string | int | bool | > | object | string | | | > | string | float | int | bool | > |--------|--------|--------|--------| >=20 > Everything else is a TypeError. Done that, does it look better now? :-) > Note that I try string first all the time. Simply because it makes no > difference for PHP afterwards, e.g.: >=20 > function f(string|int $a) { > if ($a =3D=3D 1) echo 'foo'; > } >=20 > f(true); // true ~> '1' ~> 1 =3D foo >=20 > Even if the change I applied is not intelligent and is not a good idea > (haven't thought about it deeply), the presentation as a table should > help a lot. There is one reason, it must not be inconsistent with strict types. = Switching from strict_types=3D1 to strict_types=3D0 shall always work = without semantics changes (as long as you don't catch TypeErrors). > --=20 > Richard "Fleshgrinder" Fussenegger Thanks, Bob=