Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87200 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26147 invoked from network); 16 Jul 2015 15:23:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2015 15:23:20 -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.41 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.216.41 mail-vn0-f41.google.com Received: from [209.85.216.41] ([209.85.216.41:37197] helo=mail-vn0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/C0-16799-76CC7A55 for ; Thu, 16 Jul 2015 11:23:20 -0400 Received: by vnav203 with SMTP id v203so8381578vna.4 for ; Thu, 16 Jul 2015 08:23:17 -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=U/cToN8VB1chSsg7rDW3IZ5TYD9BDR0t7mR4pebHdCA=; b=YSCUz0ETB9XLALfz/GwwuN1jON2hqOafngVVfR1/gp0s8IZJlSRWeTKzk89EtrfWAT yDGS3ZkLyzY0Qw7pIB8lyLYC40AiRB1H9lyhkU5QvIrISDr2KfueO/0NqPs8VzU5zVga kkZ4ydzf/filphMcnqpoOc76uZde53z2xyi8Da6npLRrlhUSRyoyu7X4GA768dusRG9X ju3Iv31F3o3EHY64Xs7MBFt7ZVRc/MO71X6got7RekNZsuhme8Zn3zPCW6n1YAvssmxl s4Xemqs3GreVMck+4VQDTFOsR4wTiugunu8amDjTJKbwJZ2vNqta9aflIBUB6w1Fu87i m6ZQ== MIME-Version: 1.0 X-Received: by 10.52.171.199 with SMTP id aw7mr11055302vdc.87.1437060197489; Thu, 16 Jul 2015 08:23:17 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.31.16.68 with HTTP; Thu, 16 Jul 2015 08:23:17 -0700 (PDT) In-Reply-To: <55A789B5.60906@php.net> References: <1436967838.8300.16.camel@kuechenschabe> <47DA8928-322C-4869-809F-BABDCA20FFB5@gmail.com> <55A778C7.1040100@gmail.com> <55A789B5.60906@php.net> Date: Thu, 16 Jul 2015 09:23:17 -0600 X-Google-Sender-Auth: doWWYZnAOdW2frE7l5Nf0wFP_8o Message-ID: To: Michael Wallner Cc: Rowan Collins , 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 4:38 AM, Michael Wallner wrote: > On 16/07/15 11:26, Rowan Collins wrote: >> Benjamin Eberlei wrote on 15/07/2015 21:19: >>> >>> But instanceof and anything related to Reflection or get_class or >>> relevant code will fail on array. >> >> >> Ah, yes, I hadn't thought of reflection type things. I don't think >> instanceof would be a problem, because checking for any class or >> interface other than Traversable would correctly return false; not sure >> if it would make sense for "array() instanceof Traversable" to return >> true or not... >> > > Maybe some pseudotype like callable (e.g. iteratable) makes more sense then? People have talked about creating types like so: type Iterable = array | Traversable; which could then be used as normal: function foo(Iterable $f); I understand that this is the second feature I have mentioned in this train of thought that has not yet be officially proposed, but I think it's relevant. Why special case a pseudo-type if we can have a generic way of making them in user-land?