Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87202 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30689 invoked from network); 16 Jul 2015 16:01:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2015 16:01:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.43 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.216.43 mail-vn0-f43.google.com Received: from [209.85.216.43] ([209.85.216.43:34792] helo=mail-vn0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/81-16799-465D7A55 for ; Thu, 16 Jul 2015 12:01:40 -0400 Received: by vnbf7 with SMTP id f7so8501473vnb.1 for ; Thu, 16 Jul 2015 09:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=/zW7mRW+eD/B+rfMZ812/OFNtpdFjFsqU379UNXHb+A=; b=zK0mOrbul4jWCjjtviZR3sr2De4DGhmgcx6sjQVylOzhKr0ILaZXTB0Uu5FBfnIgu6 ehdJP84y3AZOxYOjs4C/qYb4doMFBK5I9tcCzkZ1qtmw7rR98N/bCq7kIBxOw+hOdNoI 0Vl5IBZN4rTEGEIwofDz4SHuQ6UbZfQ0F1d52yO/Wx7AKnHE5IcxjGNaE+/pDuc1Lyj/ 7L6tO4/Gys4S2nTQtXDaf2a/FmtvRNFpqKATrIrW2Nq9P48dx/xycyMA+YzR2UY+NLql 0sprC+Lwc143vhjy7l6FholJ8RJTiNMifpgiwUhgLweMQ5wUzIxCEpNHp0QCGa9kFIyi f5eQ== MIME-Version: 1.0 X-Received: by 10.53.5.37 with SMTP id cj5mr11035348vdd.34.1437062497760; Thu, 16 Jul 2015 09:01:37 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.31.16.68 with HTTP; Thu, 16 Jul 2015 09:01:37 -0700 (PDT) In-Reply-To: <55A7D0DC.8090804@gmail.com> References: <1436967838.8300.16.camel@kuechenschabe> <47DA8928-322C-4869-809F-BABDCA20FFB5@gmail.com> <55A778C7.1040100@gmail.com> <55A789B5.60906@php.net> <55A7D0DC.8090804@gmail.com> Date: Thu, 16 Jul 2015 10:01:37 -0600 X-Google-Sender-Auth: Y5He3lOx9a-JWQ1ATOyD7dh2nUQ Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Consolidation of Traversable and array operations From: levim@php.net (Levi Morrison) On Thu, Jul 16, 2015 at 9:42 AM, Rowan Collins wrote: > Levi Morrison wrote on 16/07/2015 16:23: > >> People have talked about creating types like so: >> >> type Iterable = array | Traversable; >> >> which could then be used as normal: >> >> function foo(Iterable $f); > > > I kind of like this idea. > >> Why special case a pseudo-type if we can have a generic >> way of making them in user-land? > > > Well, for the same reason as large amounts of the core library exist (and > PHP's is small compared to some): standardisation and ease of use. I think > "array | Traversable" is a common enough use-case that it deserves a > built-in name, even if a userland naming system is available. I assume if `type Iterable = array | Traversable` can be built in user-land then it will be done using the same mechanisms in core (meaning it wouldn't be a special case or one-off type).