Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92869 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31299 invoked from network); 28 Apr 2016 15:49:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2016 15:49:54 -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.82 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.82 blu004-omc2s7.hotmail.com Received: from [65.55.111.82] ([65.55.111.82:62881] helo=BLU004-OMC2S7.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/90-28296-F1132275 for ; Thu, 28 Apr 2016 11:49:52 -0400 Received: from BLU436-SMTP53 ([65.55.111.73]) by BLU004-OMC2S7.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Thu, 28 Apr 2016 08:49:50 -0700 X-TMN: [K058RS5t2z1GVW9LTb0HiASnj6q0Ptla] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_E8BC8D40-4DD0-4957-ABD4-BBEAA9C43647" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Thu, 28 Apr 2016 17:49:44 +0200 CC: Josh Di Fabio , Levi Morrison , internals References: To: "guilhermeblanco@gmail.com" X-Mailer: Apple Mail (2.2070.6) X-OriginalArrivalTime: 28 Apr 2016 15:49:46.0865 (UTC) FILETIME=[97104610:01D1A165] Subject: Re: [PHP-DEV] [RFC] Intersection Types From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_E8BC8D40-4DD0-4957-ABD4-BBEAA9C43647 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > Am 28.4.2016 um 17:11 schrieb guilhermeblanco@gmail.com: >=20 > Nice! >=20 > I've read the RFC and there's only one missing thing that is either > undocumented or missed during patch creation: instanceof. > I'd be amazing if we could do: $foo instanceof Foo & Bar >=20 > Cheers, >=20 > On Thu, Apr 28, 2016 at 5:00 AM, Josh Di Fabio > wrote: >=20 >> On Thu, Apr 28, 2016 at 4:54 AM, Levi Morrison wrote: >>> Internals, >>>=20 >>> As alluded to last week I have another RFC for improving the type >>> system: [intersection types][1]. >>>=20 >>> It allows parameters to define multiple type constraints that must = be >>> satisfied. Common combinations of our built-in types include >>> `ArrayAccess & Traversable & Countable` and `Countable & Iterator`. >>>=20 >>> Some people have suggest I merge this and union types into one RFC. >>> For now I'll just proceed with them separately to gain feedback. >>>=20 >>> [1]: http://wiki.php.net/rfc/intersection_types >>>=20 >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>>=20 >>=20 >> To me, it seems that intersection types are more useful than union >> types (other than the obvious null|Foo and array|Traversable cases) = as >> they'd allow us to write smaller interfaces and better follow ISP in >> userland, with interfaces becoming much more convenient for >> documenting the requirements of a parameter. >>=20 >> At present we tend to have incomplete implementations of interfaces >> (e.g. throw OperationNotSupportedException). Union types would allow >> us to create more, smaller interfaces and avoid situations where the >> type of a parameter doesn't accurately reflect the method's true >> requirements, or where concretions are incomplete implementations of >> an interface. >>=20 >> Thanks for your efforts, Levi, I'm excited about this one! >=20 > --=20 > Guilherme Blanco > Lead Architect at E-Block Who=E2=80=99s top-posting here? ;-) Regarding your suggestion, $foo instanceof Foo & Bar is conflicting with = bitwise and here. Anyway, you already can $foo instanceof Foo && $foo = instanceof Bar. Which is IMO just as easy, not conflicting and more = flexible. Also, instanceof would not (at least not currently) work with scalar = types, array or callable. (i.e. $foo instanceof string doesn=E2=80=99t = work). And thus $foo instanceof Foo & callable doesn=E2=80=99t either. = Which is quite a difference to intersection/union types. Bob --Apple-Mail=_E8BC8D40-4DD0-4957-ABD4-BBEAA9C43647--