Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114581 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22419 invoked from network); 25 May 2021 10:40:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 May 2021 10:40:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 91FD01804CC for ; Tue, 25 May 2021 03:51:30 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 May 2021 03:51:30 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id t206so16492310wmf.0 for ; Tue, 25 May 2021 03:51:30 -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=G78auodha/IFJF3ouscQFLc3qa2cl7BDg8TCq9bn0Yg=; b=QehFkGoIppe/Pz1b0aZdATYsWr8hrfPYGm30aIu8RACAAcBywUFEwiUbQmg96ab/PO X7B1mThSJawx39D1sHhWBYXUUM+ASsVCniZeFgYf1pXDGkomhikAz7QvyONbbgJECnPT IkXiE2e3G8ucLfOalU61oIRnC8Ox3tGNRNkTqbh49RM1gOmB2KlE6FbDEbmW0xBnyCJf BLGRKS3PBe6s7sMVp40C9dlAp1taoJR0z37tlwtbLoAdREh1mmXEQoBegFoA52coUOWC TnjU5Zoe21SJeqKg+2kc/ix1w4GYMo48q7xhYUIgwk9Ru8zxom2PdhFqX1Tabdjs6U0Q KPDQ== 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=G78auodha/IFJF3ouscQFLc3qa2cl7BDg8TCq9bn0Yg=; b=V5QY3wgtB5W4jrOydx67KOoTp/qY8VHSOweyYiw+IztnaCMUXmsaSCtLsb49wgHqJW PLY8S2bWbJkwxwNS4nBTkn74NGsyDRSaFccaui61jJqZ8wj0i6sQSNJX4fnMDO6qzPwd BXqRA6GXLqSCGwjLnywilFr2UE9b2R3YlYdJBxTcNsxg8UVa2qDnb4fqrDvTkO6a12hx jwNlQ6/fWWf9/ch+J9PkuRQ+Kp7UnacAZ3z5RBL11pU8D7pbpSOsyeTUlw/5Q4C0OHfx J41qo/yyDJ3DS5xIXId8q5ZytYSf4f07UjRY9qw7M+yUFytVKSsauBpoJkbuuQuyWMQ2 36kA== X-Gm-Message-State: AOAM533kO5SxfTvAWXbLWsd3uOf9Z+XZ4Mogens4UEPoRBd5p3HnQw+Y 2LZeYsonzd2hnnJ9kU0/9b2kB3w5cwEqlKCxcJo= X-Google-Smtp-Source: ABdhPJwRoKt7Cb9m7zU6tVmfbeKMjoItgpy/6c6T16mPUz5rXUJbyhSF+C8up8dDHSTiKkUi0P+7VVmk4hthf0R/Qh8= X-Received: by 2002:a7b:c346:: with SMTP id l6mr23230792wmj.109.1621939888838; Tue, 25 May 2021 03:51:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 25 May 2021 13:51:16 +0300 Message-ID: To: Karoly Negyesi Cc: Marco Pivetta , Lynn , "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] A little syntactic sugar on array_* function calls? From: someniatko@gmail.com (someniatko) > The proposed syntax > > $array |> array_map($fn1, ?) |> array_filter(?, $fn2) > > When I compare to: > > $array->map($fn1)->filter($fn2) > > 1. It's longer. Much longer. > 2. It still requires knowing where the array goes. That's legacy which we could sidestep with the arrow notation. > 3. Admittedly, the pipe is much more powerful. While the argument No. 2. is completely valid, the 1st one is not so. If you remove whitespaces around the `|>` and also if you alias these functions to `map` and `filter` respectively (or if, for instance, some future RFC moves them into a special `PHP\Array` namespace, which would probably never happen, but it's allowed to dream), it could look like this: ```php $array|>map($fn1, ?)|>filter(?, $fn2); $array->map($fn1)->filter($fn2); ``` A bit longer (due to 2.), but not that much, actually. Best wishes, someniatko