Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103373 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55385 invoked from network); 23 Oct 2018 07:00:50 -0000 Received: from unknown (HELO mail-lj1-f194.google.com) (209.85.208.194) by pb1.pair.com with SMTP; 23 Oct 2018 07:00:50 -0000 Received: by mail-lj1-f194.google.com with SMTP id z21-v6so38953048ljz.0 for ; Mon, 22 Oct 2018 20:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xhOjZ9dgFwNcWM1UcGpvRLxGU8r7xMwUSz/p3A+MHAQ=; b=W8BDVcM4t6coWTevUF756vtfwiHGXo6WjP/W+1epkoIOKKVe1FDxIIHOLmNU4kKqoj QghP8z+VvkytD06aFydYtK6K2q5/sUrbDBZyvUEhOKQXDbyefWZbLXzJK+nlvfhd2KdD n1s7dAAwoHVgg7Ys+0m4IqgpEjrjtsS6FBcnh0Ocu15kLqrS6X5IBryxJ3IX057yy1ba ksVCOnoB44G8Ma29LpPNVp7/16sFCXnNaBcArZSMpKRHFt29ASxlMBlG+rfEA6jEYJew 2bjTiUgc4xIXVKIdW8KgitzJXQii1doOaxtVkX/dk7olYsZU0BQd07p0b1eUUDdVt97H 6M9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xhOjZ9dgFwNcWM1UcGpvRLxGU8r7xMwUSz/p3A+MHAQ=; b=sqNQRh8EQgZETsNzti3okgFmgBRPZvblxQkeUFFNVTcoq3Y8Bm8QSYnw0QVwEinINg M3ClYRhz6/Xr/JcCvQgTPxqc4gnEQAsz6zh1VeZ/lyyASNKY87ImBFpe69PgnEJLMIQe yz8IkXwPW6Yb8PZBxsr/pt4/786QRAIPIlPsaKitKdY97tV3ckLId/6/jI4Ey5p+0mJP dgO6ivGzFqdzwOz+Tcwk9zCK06dTIjKPvb2VxP9eetfc7F4IaRGvkG0Lp1ewSFl7IawJ hl0ASmIej+bVzV0PmyLWAYnUj4ufR8EvxN78pNAB4YTABKBzn1SQTc7exzloQIjuRD4E Qo6A== X-Gm-Message-State: ABuFfohWLELr2MltbMqwMMfk+/5HWDyTe6DRS/8hvvlbW6gWv/mPTyMc AOzuKwSt9mur47sZLezU+Wwd5Iomchk02mWffBM= X-Google-Smtp-Source: ACcGV635EZo/olQc8U4Q7tlffnvcW+MXipgBTmYAfa5YvXM/LvADjvPZyHWgapupdpu1Yyb3GuIp1ZrJV9xOo0rrxZE= X-Received: by 2002:a2e:9ec5:: with SMTP id h5-v6mr15541867ljk.40.1540264536638; Mon, 22 Oct 2018 20:15:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 22 Oct 2018 23:15:25 -0400 Message-ID: To: levim@php.net Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [PATCH] Implementing array_every() and array_any() From: bugreportuser+php.internals@gmail.com (bugreportuser) On Mon, Oct 22, 2018 at 1:39 AM Levi Morrison wrote: > > On Sun, Oct 21, 2018 at 10:04 PM bugreportuser > wrote: > > > > Hi everyone, > > > > A patch for array_every() and array_any() was abandoned from inactivity, > > so I wrote a new patch for it: > > > > https://github.com/php/php-src/pull/3597 > > > > There was never an internals@ discussion that I can find, but there are > > some comments on the old pull request. Most of what I changed was not > > including a traversable type in the same patch, since > > https://bugs.php.net/bug.php?id=76865 was opened. > > > > Any thoughts/comments? > > > > Thanks > > I think this is too small in scope, but... I've seen it come up more than expected. Sometimes not as a function: https://git.io/hfclelde https://git.io/304ffwgx https://git.io/8fsbhqvw https://git.io/bz4c9bgq It can also help for validating array arguments. > I there is some point where we should have a standard library v2.0 > which incorporates the years of improvements in the language and > experience gained to produce a better experience. I don't think we're > there yet. Some features that might put us there: > > - Generics and callable type signatures e.g. > function transform(callable(T): U $transformer, iterable > $input): iterable; > - Named parameters or parameter labels e.g. > sorted($iterable, compare: greater_than()) > > As things are now I don't think the end result would be better by > enough to warrant the effort and disruption into the ecosystem. > > So tying this back to the proposal: I think it's best to wait. It's not important but many other languages have it. It prevents adding the same simple functions to many projects. It also fits with array_sum() and array_product() which can also be implemented using array_reduce(). I think these are helpful to add since v2.0 will probably not happen soon. However, I don't have a problem closing the pull request if that's that's the decision.