Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73741 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38609 invoked from network); 18 Apr 2014 08:58:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2014 08:58:58 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.171 mail-ob0-f171.google.com Received: from [209.85.214.171] ([209.85.214.171:41287] helo=mail-ob0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/D0-33484-059E0535 for ; Fri, 18 Apr 2014 04:58:57 -0400 Received: by mail-ob0-f171.google.com with SMTP id uy5so1579077obc.16 for ; Fri, 18 Apr 2014 01:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9QfHCVlSuoPNQVXDRzOQo3G/lqaQOAic6WLnQx9NEkM=; b=KlUDcCN6WQFtyty9fCZh0j4bdogjxRzsUA9b/vCup1W8lEPsow65ZAbl82tXhY2qhb tX216WmlHzGlDPw1bmqTYnPNChMBMVArZEURYxy+Pv7egzI5WWpJ4uzdgPdeAW88fRBp r1633NNK7zoLklIjUjHit1yifswPRsTJ+Cay71DCmrzGHeO13AgEYZqbUzkOWt8jxumT P4e8fOXR6++MLRaL4KehvLaKJFq1eRbF5eBwIYFbId7BPs7PFXfhjsB7ZIX907hlI5t3 esNwgkSLKTPSdS3neDNBTycZx5v9y2TpZuodc9aUW33I6I2iKUiVEk12CukOdl4ANAwV 7L/w== MIME-Version: 1.0 X-Received: by 10.60.50.197 with SMTP id e5mr11642033oeo.39.1397811534147; Fri, 18 Apr 2014 01:58:54 -0700 (PDT) Received: by 10.182.69.101 with HTTP; Fri, 18 Apr 2014 01:58:54 -0700 (PDT) In-Reply-To: References: Date: Fri, 18 Apr 2014 10:58:54 +0200 Message-ID: To: Tjerk Meesters Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a11c2ed6cf5038d04f74d5b28 Subject: Re: [PHP-DEV] [pr-645] Add offset to reset() and end() From: nikita.ppv@gmail.com (Nikita Popov) --001a11c2ed6cf5038d04f74d5b28 Content-Type: text/plain; charset=UTF-8 On Fri, Apr 18, 2014 at 2:39 AM, Tjerk Meesters wrote: > Hi, > > I've added a PR that satisfies #31375. > > https://github.com/php/php-src/pull/645 > > It adds a second optional argument to reset() and end() to specify the > number of elements that should be skipped (forward or backward). > > Currently, negative offsets are ignored. Should we raise a notice for such > cases? Something like: > > "Negative offsets are not supported." > > Any feedback is welcome. Thanks! > The reset() part seems to already be adequately covered by LimitIterator. Personally I'd prefer not to add any new functionality to reset/current/... because you oughtn't be using those functions anyway. Trying to do manual array iteration with them is both somewhat unsafe (think nested iteration) and makes for really ugly code. // skip 10 elements of $it. Can be an ArrayIterator, of course foreach (new LimitIterator($it, 10) as $k => $v) { ... } Nikita --001a11c2ed6cf5038d04f74d5b28--