Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33451 invoked from network); 15 Jul 2015 14:31:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2015 14:31:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:35773] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/35-27477-7DE66A55 for ; Wed, 15 Jul 2015 10:31:51 -0400 Received: by wiga1 with SMTP id a1so1467917wig.0 for ; Wed, 15 Jul 2015 07:31:48 -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:from:date:message-id :subject:to:cc:content-type; bh=XK5SPUnr88SlnMiTW5+bBcW6weZ/cvHk2QOkoFuTcgM=; b=Hu251Tbe0jJ1+yVAyl+beOqkkMCqFJE6yOxZuH+CjffWmrbp2QRVgBUyrHgY5NQW2H dL2t8QAqPR9P6fZ9ZvGhDlAJ/Dne/NkEPzeZoZbJruICm9+kJkYi04/JsRDKEiSaPZYs zrXDiBwQ3GzpQFNO58f5RebWzIoReDkHaPIU4yJdo+07HLU19CybS8QYBHRFkSxNDXPk XhJuA7GQVfmzLPie/+KygxathGecVBc6hrsDIaV1NG2R/jBr5nG8uT34+mbyfv+XmfUT 0uVFVhNWTC56tKqnZTvI2LCWgiKn+LQZuAiQX4c0XU2K78cK7bHApG6yz74P1dGc4Gde SGIQ== X-Received: by 10.194.184.140 with SMTP id eu12mr8925329wjc.78.1436970708685; Wed, 15 Jul 2015 07:31:48 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.120.198 with HTTP; Wed, 15 Jul 2015 07:31:08 -0700 (PDT) In-Reply-To: <1436967838.8300.16.camel@kuechenschabe> References: <1436967838.8300.16.camel@kuechenschabe> Date: Wed, 15 Jul 2015 16:31:08 +0200 X-Google-Sender-Auth: kxFOCysVeDGXl76hEGI8Ymf8HNM Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Tjerk Meesters , PHP Internals Content-Type: multipart/alternative; boundary=047d7bacc2c0a4d8b7051aead020 Subject: Re: [PHP-DEV] Consolidation of Traversable and array operations From: jpauli@php.net (Julien Pauli) --047d7bacc2c0a4d8b7051aead020 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Jul 15, 2015 at 3:43 PM, Johannes Schl=C3=BCter wrote: > Hi, > > On Wed, 2015-07-15 at 11:28 +0000, Tjerk Meesters wrote: > > The most notable comment was that it would be nice to support Traversab= le > > as well as arrays; instead of only supporting this for my own functions= , > > I've generalised this so that other functions can take advantage of thi= s > as > > well. These are the additions: > > > > 1. A ZPP argument; the "t" (for traversable) argument type has been add= ed > > that checks for either an array or implementation of zend_ce_traversabl= e. > > > > 2. A generic iteration function, called php_traverse(); it accepts: > > a. the zval* to iterate over, > > b. a step-wise function that receives the value and key, and returns = a > > boolean that determines whether iteration should continue or not, > > c. a traversal mode (only values, or keys and values), > > d. a context that's sent to the step-wise function. > > I really like this concept to unify by access pattern, hiding the actual > implementation! > > > 3. A concrete implementation of a step-wise iteration function, > > php_traverse_until, that gets called as part of array_every() and > > array_some(). > > I wonder if we can find a better naming scheme. For some array_ > functions this will work, others not. This again feeds the "PHP is so > inconsistent"-trolls. At the moment I'm leaning towards simply using > every() and some_of() without reference to a type. Or maybe introduce, > to restart the namespace-debate, php\every(), php\search(), php > \someOf(), php\product(), etc. and deprecate array_search() etc. > > johannes > > Nikic designed "Iter" some time ago, when he finished adding Generators to PHP. Perhaps some ideas could be taken from it. https://github.com/nikic/iter I suggest writing an RFC and target 8.0, while the deprecations could target 7.X Also, there has been an open subject for ages about how could we uniform array and Traversable internally, as well as from PHP user land (the main subject was then to add support for ArrayAccess to every array_***() PHP function). I'm happy this bumps the subject up , as it is quite a hot topic. Julien Pauli --047d7bacc2c0a4d8b7051aead020--