Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99714 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51684 invoked from network); 3 Jul 2017 15:58:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 15:58:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.223.181 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.223.181 mail-io0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:33031] helo=mail-io0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/C4-15131-0B96A595 for ; Mon, 03 Jul 2017 11:58:40 -0400 Received: by mail-io0-f181.google.com with SMTP id h64so58861077iod.0 for ; Mon, 03 Jul 2017 08:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f9iTm927zRVZIoAQWIpstpIcAqbfX5JhO6rv3Wk4Yjo=; b=CAvZ/wPwAHUwdVR3ObVQUIfg/83E+UFSQ71x7iAryxf1wOK0yMehK9yGV2KZi3NIfS i9m+adEODdZ/7LLofrNcC7iFKPx9EYrkpwUDjivzq3oG29TDQHiyx+ukK44zEbOWUWqx kC+WyhpBVqykIOhdsv4YN3UA6rmDfZumFospoxa3c3bRS/fkjttdXf3hNqO9Uedy1ZLt +Y1RkB3x5m0pWBHJA7betx4w8fyhAXz9NfE8jycX9UrFq09+fuWFqgHKH07A3YP65jek BZLXq8vK2TZR8hgobfTJPxm2m+6hLcwVWjptbVbx3iKjx1lNC3eUftTzKoXmGF4rb/P9 Ta8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=f9iTm927zRVZIoAQWIpstpIcAqbfX5JhO6rv3Wk4Yjo=; b=DkKoRLefVuAQNtFcMVO/MIKTr/B6zYjAR8G4rf8ayG14DfMb236F/nK0oOdTkosf6t Z9iBOkUHZZYvSEW5TO8Pit5BFvCNASZsk4F+MUpVYGjxroTSKLgA5OatP7XjLg/9elO+ P+6TUbrDwvv5qY353E5Vh10lUyDrVa/PIuytxAN7TWzvuoF3JkzVuQJl9uMUfiU8F2nd 11J05vqE7xvA8PeV5/tXCWeThDxnXpzgOHoiUFwk6umGe07velaVaxqzBKtgICFWwcaz lEfDE6rsXddcQ679Twd9O5XL1j+Wxhkx7EcZHpNyREjHmKiHNe3EvC7QeImmzxVzS/Om hVaw== X-Gm-Message-State: AKS2vOwr3W4mzQ4qewz35u0JEt6aTKJO1qTBwRKQ6q3psgEpESCZBiWF fom4Zcv56TNr9maTdVE= X-Received: by 10.107.29.6 with SMTP id d6mr33589799iod.34.1499097517319; Mon, 03 Jul 2017 08:58:37 -0700 (PDT) Received: from mail-io0-f172.google.com (mail-io0-f172.google.com. [209.85.223.172]) by smtp.googlemail.com with ESMTPSA id u128sm5529026ioe.40.2017.07.03.08.58.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 08:58:36 -0700 (PDT) Received: by mail-io0-f172.google.com with SMTP id z62so58845159ioi.3 for ; Mon, 03 Jul 2017 08:58:36 -0700 (PDT) X-Received: by 10.107.154.12 with SMTP id c12mr35239882ioe.228.1499097516617; Mon, 03 Jul 2017 08:58:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.246.71 with HTTP; Mon, 3 Jul 2017 08:58:16 -0700 (PDT) In-Reply-To: <1499095625.19635.52.camel@schlueters.de> References: <1499095625.19635.52.camel@schlueters.de> Date: Mon, 3 Jul 2017 17:58:16 +0200 X-Gmail-Original-Message-ID: Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] "Reader" as alternative to Iterator From: andreas@dqxtech.net (Andreas Hennings) On Mon, Jul 3, 2017 at 5:27 PM, Johannes Schl=C3=BCter wrote: > > Wouldn't SPL's NoRewindIterator be enough? > > $nit =3D new NoRewindIterator($it); > > foreach ($nit as $row) { > break; > } > foreach ($nit as $row) { > // continues same iteration > } I had not noticed this class :) My motivation was to be able to use iterators and readers interchangeably. Readers are easier to implement as classes. Iterators have the benefit of the generator syntax. The idea is to have a library where some stuff is implemented as reader classes, and some other things are implemented as iterator classes. Then for the actual operational code, I need to choose to use either iterator syntax or reader syntax. So either I need adapters for all iterators, or I need adapters for all readers. The NoRewindIterator would make it more viable to work with iterator syntax on operation level. So yes, it is a helpful hint. Not sure if it makes me fully happy.