Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9071 invoked from network); 2 Jun 2016 17:52:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2016 17:52:54 -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.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:58356] helo=mx207.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/87-62101-57270575 for ; Thu, 02 Jun 2016 13:52:54 -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 1b8WnZ-0000R0-UT; Thu, 02 Jun 2016 17:52:50 +0000 Reply-To: internals@lists.php.net References: <0A.C5.62101.1C860575@pb1.pair.com> To: Bob Weinand , Andrea Faulds Cc: internals@lists.php.net Message-ID: <64cafa7a-2426-6c54-8e48-f060ab1edaf9@fleshgrinder.com> Date: Thu, 2 Jun 2016 19:52:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="o0DxHl67tSH7t0rWTLeJOAvVffRWDctCV" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: php@fleshgrinder.com (Fleshgrinder) --o0DxHl67tSH7t0rWTLeJOAvVffRWDctCV Content-Type: multipart/mixed; boundary="R6D67s3PnnTjFUUnJbLRK9SIFf4qEIxCM" From: Fleshgrinder Reply-To: internals@lists.php.net To: Bob Weinand , Andrea Faulds Cc: internals@lists.php.net Message-ID: <64cafa7a-2426-6c54-8e48-f060ab1edaf9@fleshgrinder.com> Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types References: <0A.C5.62101.1C860575@pb1.pair.com> In-Reply-To: --R6D67s3PnnTjFUUnJbLRK9SIFf4qEIxCM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 lossles= s 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 t= rivial 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 Don't you think this matrix would be a better presentation and simpler? |--------|--------|--------|--------| | type | #1 | #2 | #3 | |--------|--------|--------|--------| | bool | string | int | | | int | string | float | bool | | float | string | int | bool | | object | string | | | | string | float | int | bool | |--------|--------|--------|--------| Everything else is a TypeError. Note that I try string first all the time. Simply because it makes no difference for PHP afterwards, e.g.: function f(string|int $a) { if ($a =3D=3D 1) echo 'foo'; } f(true); // true ~> '1' ~> 1 =3D foo 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. --=20 Richard "Fleshgrinder" Fussenegger --R6D67s3PnnTjFUUnJbLRK9SIFf4qEIxCM-- --o0DxHl67tSH7t0rWTLeJOAvVffRWDctCV 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 iQIcBAEBCAAGBQJXUHJkAAoJEOKkKcqFPVVryxAP/1V6iewRj7P/KwnIpmfKP6iD 3+7DTXKQs3vQPjqNfQrI2lOB2fSSWE+FqaTiKpuYOz7eBdKaIQanMQdcox/K+aCr 7p+aVsGK/3+HcHwzBaFSQC2hTeVELRJyjO+rRWPHgui6Qfhb1amTI5aqYrYmEzrg Eq/FdKdm/PH5KAEGwKmLe3bsKpqrTqIdNR4QZhAyXIVy4f+JOe+MkhqbVN+ypDR0 Xh1KCgI1fjcNg0WE5avA5G9PXvUpevdAe1tUdrVX0T+e58CquZleDJ4B2UpnXQKi p0Oy5tPP4rmQVrVdyIX/xTlHiqfqVeu1u0iZb8lIMUMxnw96jYCSKtXaaeyw9Lw7 NVkGdM5YavZZxlK1uOhVck88vkCDcL67eqE8TlACktPWcgUwPh5FklbANvEPKIwg 7cgDz5Kejw00/2D/ZndCuDkZfrn/uh7nd1ocMrncerS4OJ5CXQ2HUj0NqnTTCtid v0iX6mkS0YANIulA9qOaxhgPTCxKepG3M4TE0+bt+dEKU6tdUmgweKR/IuIDdZY9 9mwaJcTie0QlDAfjNMpYTID0tzzyYeas0z71I3LeDrcHdNNkBgDz4IKehPG6rOqI xUetCRWjtGYs2VxT73N4scKb/h1pnMSTRB/2mKnpbTRvQAFkLyWV8uT+UOasybLT GyhzNY4GJoYLaFk0/Icl =6JMS -----END PGP SIGNATURE----- --o0DxHl67tSH7t0rWTLeJOAvVffRWDctCV--