Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93758 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19706 invoked from network); 3 Jun 2016 19:18:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jun 2016 19:18:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.89 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.89 mx108.easyname.com Received: from [77.244.243.89] ([77.244.243.89:44157] helo=mx204.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/25-22497-FF7D1575 for ; Fri, 03 Jun 2016 15:18:24 -0400 Received: from cable-81-173-133-15.netcologne.de ([81.173.133.15] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1b8ubs-0000Yn-1H; Fri, 03 Jun 2016 19:18:20 +0000 Reply-To: internals@lists.php.net References: <0A.C5.62101.1C860575@pb1.pair.com> <9A.32.22497.9AE91575@pb1.pair.com> To: Andrea Faulds , internals@lists.php.net, Bob Weinand Message-ID: <903451a3-99f7-5420-a4da-8b8919968754@fleshgrinder.com> Date: Fri, 3 Jun 2016 21:17:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <9A.32.22497.9AE91575@pb1.pair.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ENSDRAM9oxJLdprjx8b8dLXRRwvnbOMj3" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: php@fleshgrinder.com (Fleshgrinder) --ENSDRAM9oxJLdprjx8b8dLXRRwvnbOMj3 Content-Type: multipart/mixed; boundary="2QTNS9QMo8uUnf6Bf8O5Iol8gMMooHaIF" From: Fleshgrinder Reply-To: internals@lists.php.net To: Andrea Faulds , internals@lists.php.net, Bob Weinand Message-ID: <903451a3-99f7-5420-a4da-8b8919968754@fleshgrinder.com> Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types References: <0A.C5.62101.1C860575@pb1.pair.com> <9A.32.22497.9AE91575@pb1.pair.com> In-Reply-To: <9A.32.22497.9AE91575@pb1.pair.com> --2QTNS9QMo8uUnf6Bf8O5Iol8gMMooHaIF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 6/3/2016 5:13 PM, Andrea Faulds wrote: > The RFC uses simple rules, but the resulting behaviour is complex. >=20 > PHP's weak typing rules are complicated enough as they are, and cause > enough problem, without the addition of yet more rules, this time for > how weak typing should work within union types. >=20 > I don't think 2 days is enough time to discuss this before voting on it= =2E >=20 I actually agree with Andrea on this. There are too many side effects that are endlessly hard to cover; even if we put all our brain power together. I would actually propose to make them always strict. It should not be a problem for people to simply cast them to the right type. Maybe it even helps to prevent that people overuse union types (which I am a bit afraid of too but the feature is too useful). In the end, anyone who does not like it can always resort to using no type hint at all as they could in the past. I know that Bob already said that it is a no go but I do not quite agree here. That being said, there is another possible approach. Do nothing in weak mode. This might sound weird but the fact that the engine will coerce the variables anyways as needed would help. Any union type would be mixed again, like it always was up until now. A problem every PHP developer knows about and knows how to handle. In the end it is about relying on super type behavior. If I accept float|int|string than I should only perform actions on them that all of them support and I have to check the actual type anyways if I want to change my behavior based on the specific type. Hence, I can also error out if I do not receive the type I was expecting. As we are already doing. :) --=20 Richard "Fleshgrinder" Fussenegger --2QTNS9QMo8uUnf6Bf8O5Iol8gMMooHaIF-- --ENSDRAM9oxJLdprjx8b8dLXRRwvnbOMj3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXUdfqAAoJEOKkKcqFPVVr84QQAJ1NEDp6f3b9hLDpzb/jmWWF jpPjo2hX7uhgv8CmAK3sTs1eo4aHtvIM4EWAJdwGQRD07QK7OoJtkIlv70CMB3kc UkHu4XuxD83XPNNf1FixxHFudk+8EID9zlKJoZTEF3LqprAnF/6r5jVTE+ctkf8T Wg0Qx5YwyWWnOW+0fHsgdTyBc7msdysKo6VCj6GKgJdF0IPynGCSUEKhFurnk10I caltfyhWPFow5xHcj4mm7zen1SvU19WbLhlcoc1Tra57usxO04rBO77TVfeAaG3y vg94WgnptqUxKANVRWqTF9/6a72eQaXsx0CF+7RVYXCHJKdPy3etYk1F/6CMBD9Z 3587jZGhOshLqv/8vDYDlWueBAZvmU1FpjtNMFmXAtxxuYr4UT55wcTTVQuGLuyS auRTeFh/kzFXVVG6R0uafbfY5FqUSD/56XgcVfWn9nyQIi59B5SsiZiChQHhGywC OiEB895ET4PAI8lwSAoihjHkPLYcg2FbYR4TSK7BRs/sC4rd++pkOTpqkvke5hme vkm02ppmx3rGxwQ+wgqacc8iX6UoHkHhWLfev55EcXhhSVnUIZTttlWs0wLhbbXu A/Wu4yyLXPvynbJrc6TDRzjNpaXm4qEkGwvyW4gzhp2pqoctbIipr3Z/R4XmZhLp uuzFFAGMD2DNvGQ68fH6 =JR0W -----END PGP SIGNATURE----- --ENSDRAM9oxJLdprjx8b8dLXRRwvnbOMj3--