Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93767 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71016 invoked from network); 4 Jun 2016 14:37:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 14:37: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.88 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.88 blu004-omc2s13.hotmail.com Received: from [65.55.111.88] ([65.55.111.88:65213] helo=BLU004-OMC2S13.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/65-25194-AB7E2575 for ; Sat, 04 Jun 2016 10:37:47 -0400 Received: from BLU437-SMTP63 ([65.55.111.73]) by BLU004-OMC2S13.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Sat, 4 Jun 2016 07:37:44 -0700 X-TMN: [bX8BApZkIe7ov0Z/FONBprbT7m0XbRMV] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <9c759795-a702-4f02-7eba-f1bd6fcb4ec2@gmx.de> Date: Sat, 4 Jun 2016 16:37:38 +0200 CC: Keller Niklas , Larry Garfield , internals@lists.php.net Content-Transfer-Encoding: quoted-printable 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> <20160603142421.346B81A81725@dd1730.kasserver.com> <9814df22-9854-616b-bf02-d0742efefaff@gmail.com> <20160603145857.8413F1A8323C@dd1730.kasserver.com> <1fb072b3-9b9e-1dfd-6b39-7875587b6c7d@seld.be> <5751B50F.2090003@garfieldtech.com> <9c759795-a702-4f02-7eba-f1bd6fcb4ec2@gmx.de> To: Christoph Becker X-Mailer: Apple Mail (2.2070.6) X-OriginalArrivalTime: 04 Jun 2016 14:37:41.0422 (UTC) FILETIME=[A62ECCE0:01D1BE6E] Subject: Re: [PHP-DEV] [RFC] [PRE-VOTE] Union types From: bobwei9@hotmail.com (Bob Weinand) > Am 4.6.2016 um 16:17 schrieb Christoph Becker : >=20 > On 04.06.2016 at 14:15, Bob Weinand wrote: >=20 >>> Am 04.06.2016 um 13:45 schrieb Niklas Keller : >>>=20 >>> For Aerys\Host it could also be solved with an interface that just = doesn't have any methods. With the disadvantage of callable not being in = the same signature anymore. >>=20 >> Also, it requires you to inverse responsibilities. You'd have to = specify a common super-interface on every single fundamentally unrelated = interface (which are only indirectly related by the fact that they = receive common handling in a single place). That's a clear anti-pattern. >=20 > I agree, but I can't see why using a union type would be much better, = as > you would still bundle up a bunch of "fundamentally unrelated > interface"s in a single (union) type. While I see a small benefit in > the explicit notion of the union type in the function's signature, = that > would completely vanish if we introduce some kind of type aliases = later > (as already noted in the "future scope" section as potential = improvement). Even if we introduce type aliases, the aliases will still have to = contain unions by then. (And then it=E2=80=99d be weird if you could use = them in aliases decls but not inline =E2=80=A6 huh?) Also, the interfaces are _locally_ handled the same (i.e. in the = structure passing it forward), but in the big image they are not. >> Additionally, this is only possible if you are actually in control on = these classes and can change them. If you pull them from a library, no = chance. >=20 > In which case it might make sense anyway to use adapters. For which you then need an adapter for each and every combination of = interface (power set without empty set; 2^n - 1 - 15 adapter classes for = 4 interfaces). That=E2=80=99s not a practical solution here. Bob > --=20 > Christoph M. Becker