Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93368 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85214 invoked from network); 17 May 2016 10:55:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 May 2016 10:55:07 -0000 Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-io0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:36439] helo=mail-io0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/00-19201-B88FA375 for ; Tue, 17 May 2016 06:55:07 -0400 Received: by mail-io0-f181.google.com with SMTP id i75so17911953ioa.3 for ; Tue, 17 May 2016 03:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=FFFp3lfUmvSyvh6FtsAyyq4KlC5PpI00V1+/cHvEwxc=; b=U9kTJ/vZ5BGwamHY4CnVIRbw2deUcnhNw9AHX8uQmnfX4TyqaqefSNML8TnjZImboR Yffo9LEXGfwgeQ7f39uOnM/YmxDZz7ivhVZ7H5hCzLAmDbQl4C/trHV6BX7kacry9Ec0 OqplpO6drhKbHsAb/p504OgrdZTOpK51KokJBrfOuCLOQW6XFfUhtu0ex+JQIb99UAhH wHRjLynPc53969lvVWPXXa2ON26mtfD4l5FAoSdzdjpDjGvZ572viG1rgT2IR5HCjTya /06bcZy8PBS4lNpGX1CR1f4uppHRdZLYtYWYjzRkbDePKw+0Hq4hLXGKnuugt4bHZfAQ UqYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=FFFp3lfUmvSyvh6FtsAyyq4KlC5PpI00V1+/cHvEwxc=; b=D1qjkXQMMxLJH/xvLr6dfDns9Vceu3JcljCoORFgQ82cZ37Bt6lF8koOMZ0OQ9Zoq7 47iajzzHsN7+rKY0PrC3Oi50/yghCzSgif+iXiaD67pyPIfxp0whEji3o2iOPFfrlKL7 SAgpM0CB3H/DZS0cpiiAQ/WT1kf9xMoGACiY+pTUy4/p+eLqxpBo5wmALcdJN5MmV7P8 Ox4qApfwwntzRxyIzsNKVijiTHRgPHrpwb3GLE5KYIPSwLSGEO4BfJFSx08PgWEqNqRR uL/Le9Hz8Xvh44FJlnlaI/jiEqGOC4/9+JexEOuQZBZ14m14llGn4GHKPaV00t9FDhts JO4g== X-Gm-Message-State: AOPr4FUaFngVoCvuOzRUboxnXXdSulksP1sPUeWYhJy2MRSFFdR4qQo2eqMGP5E1fHDrictapEqZxXRZqbWY7w== MIME-Version: 1.0 X-Received: by 10.36.117.75 with SMTP id y72mr12398829itc.56.1463482504219; Tue, 17 May 2016 03:55:04 -0700 (PDT) Sender: jesseschalken@gmail.com Received: by 10.79.139.197 with HTTP; Tue, 17 May 2016 03:55:03 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 May 2016 20:55:03 +1000 X-Google-Sender-Auth: QR-gtDHpFJ3Ov2f8E9Et2HVZYmw Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary=001a114abef0cc95be0533079264 Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: me@jesseschalken.com (Jesse Schalken) --001a114abef0cc95be0533079264 Content-Type: text/plain; charset=UTF-8 Not sure if it's already been mentioned, but I've noticed this operator would be useful when you want to modify something but need to transform it before and after. For example, I have a class that serializes/deserializes arrays of strings, and I need to modify the array that it has encoded. The code currently looks like this: $id = StringList::encode(array_replace(StringList::decode($id), $replace)); The parallel between the encode and decode can be made more obvious by writing it as a sequence of steps: $id = $id |> StringList::decode($$) |> array_replace($$, $replace) |> StringList::encode($$); Neat. A similar example is when you need to modify a percentage as a factor: $percent = $this->modifyFactor($percent / 100, $this->moreParams(), Blah::moreParams()) * 100; This could, arguably, be better written better as: $percent = $percent |> $$ / 100 |> $this->modifyFactor($$, $this->moreParams(), Blah::moreParams()) |> $$ * 100; On Sat, Apr 30, 2016 at 5:58 AM, Sara Golemon wrote: > This is one of my favorites out of HackLang. It's pure syntactic > sugar, but it goes a long way towards improving readability. > https://wiki.php.net/rfc/pipe-operator > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a114abef0cc95be0533079264--