Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92863 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4183 invoked from network); 28 Apr 2016 09:00:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2016 09:00:14 -0000 Authentication-Results: pb1.pair.com header.from=joshdifabio@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=joshdifabio@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.50 as permitted sender) X-PHP-List-Original-Sender: joshdifabio@gmail.com X-Host-Fingerprint: 209.85.218.50 mail-oi0-f50.google.com Received: from [209.85.218.50] ([209.85.218.50:33054] helo=mail-oi0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/83-14004-411D1275 for ; Thu, 28 Apr 2016 05:00:04 -0400 Received: by mail-oi0-f50.google.com with SMTP id v145so43543445oie.0 for ; Thu, 28 Apr 2016 02:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=GWyhWIXteIj1LLBLTyUmLEWgFEvFdJ9mXfSfSovntRY=; b=gttwVKvQfPsqORjFDmyRNl/ktFmoASgvaSv1kF41/tOYED14Fb1UPJhorYNqnNoAq1 A0Rvg84htz4iwLAUrm35h0pYQol6TElicXdPNW9eFcAb62n5RPpvd9kKpqoYwN8wDDnA tLP35mw7s7+slcUZ/RYxnNUdh8d38iX4p9Z26P+wr+Ty1nSFFxHzd6MudwqhYekwNPEI AqrAuaCJsWXmIYs2llC/Ps29Kgvrjk60BXM85RQmR9UjuQuroowOasMeE+ZkIU7udZvC lFd3UsvxI+av35kzTxyzJRJLKKKLlHCmNa92YAZ4vcYKCvOzBcUUBPS+Scv82/BHxiCO CNtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=GWyhWIXteIj1LLBLTyUmLEWgFEvFdJ9mXfSfSovntRY=; b=D5513/YWrzoJthmYFlUwgyk9AEIaBC0OHHrtTYyhMbILdLF2n39pFlCTtLAsAtiqTd vdHTkc7gRDun7nm7GJgHEaUXiCXs8SAwFJBMNiYDe3tC6zfqILIg+NbZszSSK8hqJeOG trkzPyBj97NOZ32LpIClqXB40X+XeNF8ykQttYrZTDmIrS+CDA56Fp0I2MpYN/dFhFCl bft6i+85MT3OEyqFy0y2eKlGVepsTbBXMU0YGOyLjY9l3+V1T6SOmfglLM/1xXEdJmEV 1JNZAk2NeOmW8rmI8o24w4dUV0pzM03jvnb7wSSvN8UjNrDMsotB+zuCbo5EphItwI8o WM/A== X-Gm-Message-State: AOPr4FXlgAf4FDWquFnL+/18YM1FiDC6Ivc5bclO+CGcPyw4GL/N0Y0Hwt4eo9J1UKs0cpACeMaRGGBdzqNMtA== MIME-Version: 1.0 X-Received: by 10.157.40.242 with SMTP id s105mr5466556ota.68.1461834001515; Thu, 28 Apr 2016 02:00:01 -0700 (PDT) Received: by 10.202.84.193 with HTTP; Thu, 28 Apr 2016 02:00:01 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 Apr 2016 10:00:01 +0100 Message-ID: To: Levi Morrison Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Intersection Types From: joshdifabio@gmail.com (Josh Di Fabio) On Thu, Apr 28, 2016 at 4:54 AM, Levi Morrison wrote: > Internals, > > As alluded to last week I have another RFC for improving the type > system: [intersection types][1]. > > 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`. > > 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. > > [1]: http://wiki.php.net/rfc/intersection_types > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > 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. 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. Thanks for your efforts, Levi, I'm excited about this one!