Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107692 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66720 invoked from network); 25 Oct 2019 12:34:18 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 25 Oct 2019 12:34:18 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 085AC2D1FAE for ; Fri, 25 Oct 2019 03:20:56 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 25 Oct 2019 03:20:55 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id q1so1820334ion.1 for ; Fri, 25 Oct 2019 03:20:55 -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; bh=kdI1uZJxAXu4HLeLSuskIvWB4dYNvfwGa3pewYwbpIo=; b=dpfo3xd1X0tL3Sp31/wx8NPrv2dE1bggzPflqqHUjhzP/ccfkbzGChe+4Juvm3gtc9 q2/OgezWCbOlUgsJeEttE8DadjGYcfpv0T6NgPdFVFxBOJcFCuw4YpcSQwcKyNtjdsih XZYNGElQ29xyimK51ME2YpaQPvOZ6KG1Qzuxhgjq2ZY8z794QB2t213AMzvxpI911oqz iuD6k3Djc8PobVCCWcivBLt7xnNXKHIuF1BZh40vgfdFfChu5JZ9wyuE/ezr57gbbdMT 0oiJH9cXsv9MJc9DfHCF9bJr3PW8ZE4QKbIyziCiTY/BC8UWoIVS/sQNzDb1MHI22jVa rSJQ== 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; bh=kdI1uZJxAXu4HLeLSuskIvWB4dYNvfwGa3pewYwbpIo=; b=OirKUJjKKEIq+tL1r6+HAzNWdHJXCFE8kbdJ60g139SfS8AOcAM5gl1EwAkn5J2uYC FLrMho1wGyICr855t/vK6e/VfFi0CFPOTeQBBYr94rRF7pPCy4AYZpQTHVwHLLyei9k1 r1htptMb5Gp8t+hD4pfDQipmTRKjzdP7/1O0VC5pX1V9kOLd4GRHkgpqbjvOBn+DSWri hTCHpAvMbug6CqCGfXqb6C0jbCBwan+G52gtYLUBHdbnbqNq9ZHaWfvPZfSRvLeBrCA+ WNOflqABmBpfeLk+rH62HqXvz3veoeW9zdBaFB49O5hIIT+xv9HQuFbHeydTbhBeQ7Rt MTAA== X-Gm-Message-State: APjAAAWOLf8Tq3T0yxNE7BD27NjiCT+5puwq8clsRlNav+e+csAoo0rS mlKrHw8P0fN6hI3KSREtF614ZK0aKGSq8j3JlJ1wGlxV X-Google-Smtp-Source: APXvYqyCTNk4Db7Y7WJYrvLceX+wqIeHm9pTpcyGzp4E4bbOB1jaOTOY2ywhfTf4yG3KgcaB8Ev3RplQCAo5lREDSqg= X-Received: by 2002:a05:6638:157:: with SMTP id y23mr3082653jao.66.1571998854272; Fri, 25 Oct 2019 03:20:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 25 Oct 2019 11:20:43 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000004bde650595b9816f" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] anti-coalescing-operator From: rowan.collins@gmail.com (Rowan Tommins) --0000000000004bde650595b9816f Content-Type: text/plain; charset="UTF-8" On Thu, 24 Oct 2019 at 22:20, Kosit Supanyo wrote: > But I think this functionality should be of something like pipeline > operator: > > // send tmp variable to the next expression unconditionally > $ret = $_SERVER['fname'] |> $user->setName($$); > // send tmp variable to the next expression only when $_SERVER['fname'] is > set. > $ret = $_SERVER['fname'] ?|> $user->setName($$); > > Also the syntax like above will be consistent with the proposed > safe-navigation operators. > I really like this idea, and it actually makes the pipeline operator itself feel more useful, too. Imagine this chain, where not only might the variable not be set, but it might not match a user, or the user might have no name: $upperCaseUserName = $_GET['user_id'] ?|> User::getById($$) ?-> getName() ?|> strtoupper($$); As well as not needing to repeat the expression each time, as you would with an "anti-coalesce", "null-safe chain" feels a clearer reading of the intent here than "if not unset". Regards, -- Rowan Tommins [IMSoP] --0000000000004bde650595b9816f--