Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89308 invoked from network); 3 Jul 2017 02:15:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 02:15:34 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:37425] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/D6-60825-5C8A9595 for ; Sun, 02 Jul 2017 22:15:33 -0400 Received: by mail-wm0-f43.google.com with SMTP id i127so93663776wma.0 for ; Sun, 02 Jul 2017 19:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ns39GOD0hf6Tlid3KATxEpVnI9RMBiwnqk7WtyIyVso=; b=NpqNu21QQxS38dMUpBr/X+Sc2Gbse0XUvBqEjsKJi4fj2HfvG8rNSqn9Rc/BUaW0ia +42/ExDw5ZVcb10hSwdjXL7a7by9aLwtnQhrFccaCSoZLjewOGqbKI6MRRUc9NXX3Wo7 +8CB02MAJBA0Wiuu+KQcbMeYduVduzzMeGgo1DNePHdzSMzgBRAthBjL3KiOCG1HTjxk dVXQOLXidicvS3SnZFCISIG0w6j0SpNVeIPu2wnvfqsO43hO9WfEihsmRFgL70bilIQt 70vDNrxBlhcahyBBrtSpUSMMzp9yY1PqD5i7tGhgKBwCfzCZkE+UImR9tiE+oMzh58ZI udeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ns39GOD0hf6Tlid3KATxEpVnI9RMBiwnqk7WtyIyVso=; b=Kvt1NYz6KZDYYs11hQf5s15xk+rn2X6WGyXnoJfC6bn6o6LHKNq5P38zpLm9EN3gpe 4u3CpR+C3NfHRArw14PeySYZz/2m3JtIwCqmUyX5WlSx2UTsj7T0fzV5I9PVC2KmJcVo UyTBaEurfBODtMP/OMDSxe6G6HGkl2OM4Ha0d02wsVIZiAbDelN2agBae94oufhMdDHv wvZ63aComgqgo6ojniP85BQnyj1R4cQIdNaN9GNALYLouIJm2WC48Oslch9GEhu0ESuO MxP9RONHJshIcmpfCdO8ZYA2O0+pVbukVX5KrBhIVAqH0WoIPLz+ULHX9PVHzrg25mND mjbg== X-Gm-Message-State: AKS2vOxqrQLy0NDDiBcPdCxp8kk3nB2SKuXCSC8xDGHVfb49trAjomhd B5Sk89vSKtdsiF+MDFa/i3sPf8lwitBchqo= X-Received: by 10.28.203.137 with SMTP id b131mr13768267wmg.50.1499048130919; Sun, 02 Jul 2017 19:15:30 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.169.139 with HTTP; Sun, 2 Jul 2017 19:15:30 -0700 (PDT) X-Originating-IP: [71.251.16.204] In-Reply-To: References: Date: Sun, 2 Jul 2017 22:15:30 -0400 X-Google-Sender-Auth: KDx3w7HEXtxmmx6iwheQwYsYOIQ Message-ID: To: Andreas Hennings Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] "Reader" as alternative to Iterator From: pollita@php.net (Sara Golemon) On Sat, Jul 1, 2017 at 1:38 PM, Andreas Hennings wrote: > Hello internals, > (this is my first email to this list, hopefully I'm doing ok.) > Welcome to php-internals! > Establish a new interface in core, "Reader" or "ReaderInterface" (*). > This interface has only one method, "->read()". > The existing interface Iterator will remain unchanged. > Rather than introduce a new kind of iteration mechanism, how about just creating a library in userspace which provides a proxy interface: class Reader implements Iterator { protected $it; public function __construct(iterable $it) { $this->it = $it; } public function current/key/next/rewind/valid() { $this->it->current/key/next/rewind/valid(); } public function read() { /* What a reader should be */ } } Then you can use any already extant iterable via: $reader = new Reader($iterable); This could live in a composer/packagist library and work on already released versions of PHP. Or is there something I'm missing? -Sara