Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93942 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28905 invoked from network); 13 Jun 2016 16:52:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jun 2016 16:52:35 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.20 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.20 mout.gmx.net Received: from [212.227.17.20] ([212.227.17.20:58425] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/8F-12403-2D4EE575 for ; Mon, 13 Jun 2016 12:52:35 -0400 Received: from [192.168.2.102] ([217.82.228.97]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MD9uq-1bDaVV3ZFc-00GWvp; Mon, 13 Jun 2016 18:52:22 +0200 To: Levi Morrison , Christoph Becker References: <8284FE1F-70EE-4DB6-A945-0C57A4C99DCC@trowski.com> <16ef864f-8378-1af3-ddfb-21dc583a4b4a@gmx.de> Cc: Aaron Piotrowski , PHP internals Message-ID: Date: Mon, 13 Jun 2016 18:52:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:v5Z0AdMIIEEZ2/U3VPZDmxql6MWjDeqn44kd0NgKZuhcS5G5IGl WATUj1xPZ4hrWigornix9sE0fudGBZc0ig+LpZeOQxHHfxPDKLk1a5TQmTv4mXo+c2rXS3a cg+IknawVPoiY91e4fJjFlfXCNzvqrxgG4dRDoK4AUFtMltxiLd5skVPQEZyZ2ErYVtabL8 UV7lbQ2KXJZUh5B6lx9Fw== X-UI-Out-Filterresults: notjunk:1;V01:K0:R/VQTOsZtt8=:yuMALJQJmBHK/D52RE+0TU axo0+lw2nP4MOHeKTUMAPzjlokFkoaf72ZtXY02wpI4WRABaX12HQw66uAeO5dI9l2OA6AFfA g1ktQmNYW4k2VPLsR68IJ03cBh1BukY1inHqKn6GXOnBY3UXy2V+26VTw3d0xY8uBfjJ5kRGT eaW3FxTcYbOZqE3DihrR4xZlfszFEwY3rcFQtBtABGVxeet8w/he8ryJqwvuILd6uBlXHz3mO G1S+AGzgy8BRWMq9Br3BQEcR9sA74ptv8WB87tLupcQ6hZikG5F/8zqJnZOqqBxx5CNZZhXFw M1FiNWOsMLjyLZGECNctRPz0LQmzQWTOxrDdTDW8frp/xGfzZSLJa9OxgDywxS0pKuzUe0S7p xe0vA7VZG16BYlK5qkqK5paqJm8IhUEeiwC9po827gssJKUnrSOvY7dQrjf5Xzdpb95iRcPGl fjhcl8B3tO8I+1QR7ZoP+HXkoyoM/Y8vdvs+4rOvzTBXyXn/QSIMKBX9T2qbyXLpkuD4cqJS5 ortNpPBlAHWCijZxu4ZTCS3gBVaW8gTldrVplyHoSZoWzrEYzfRITjcegtBGSem5hCct6OOnR 5f6plAj0Ot6nmyAfEAx/k/LD11AirRZwEjrkTgML2xUyFu/apJ9ZGnEjohAebgpeBa/Z7XGSK +g92tBVjVOaDmOOvoRvQwHqxjYmvnaC4C4VXIRJUFK3cSfVoD5I/KpjBRaLpP/4nl+NcH7IBR HMt17UFpbOaZxgdj33t14wEdA+vmXCvJG4vATOvNWGctvWSD0u6kzepcr/p1XhUnbVKLbFTHm uZul5Jx Subject: Re: [PHP-DEV] Re: [RFC] Iterable From: cmbecker69@gmx.de (Christoph Becker) On 13.06.2016 at 17:59, Levi Morrison wrote: > On Mon, Jun 13, 2016 at 5:42 AM, Christoph Becker wrote: >> On 11.06.2016 at 01:37, Aaron Piotrowski wrote: >>> I would like to propose a new iterable pseudo-type that accepts both arrays and objects implementing Traversable. Values accepted by iterable can then be used with foreach and yield from, or help to reduce type-checking logic in general. >>> >>> Please review the RFC here: https://wiki.php.net/rfc/iterable >> >> Thanks, Aaron! I definitely like this idea (I'm not sure about the >> details yet – would have to thoroughly investigate), as it is apparently >> solving a long-standing issue, and is in my opinion a cleaner solution >> than (explicitly) having to resort to a union type. > > My opinion is contrary: the union type is the cleaner solution as it > does not require special casing machinery in the engine. I agree that union types are the cleaner solution with regard to the (C) implementation. I don't think, though, that they are the cleaner solution with regard to PHP code; a developer has to think twice which guarantees a union types gives regarding the allowed operations. For instance, what would Foo|Bar guarantee? I would have to look up both respective definitions and find the intersection – and that still leaves room for errors, as operations with the same name do not guarantee equivalent behavior. The special case of reading and understanding `Traversable|array` might quickly get second nature for developers, but it's still ugly to write and read, in my opinion. -- Christoph M. Becker