Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107677 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14577 invoked from network); 25 Oct 2019 00:16:31 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 25 Oct 2019 00:16:31 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id A09102D1554 for ; Thu, 24 Oct 2019 15:03:01 -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-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 ; Thu, 24 Oct 2019 15:03:01 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id i185so22012765oif.9 for ; Thu, 24 Oct 2019 15:03:01 -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=kF6Mh7zBGTmZcZ4fgLRLs/sAGNyKsmZ+y/S5TzPnCVo=; b=kRupxHXqlcWAmOm57MTseea/g3aub1ncU4Hl1ilhQg111TPEje6ZNU4SeVxfT8po6j guKXdfNGtJZsw444oM9yBcU83ATDdR/w3ovZGoTynPJk6O10UhewbVuuTu9YvlzqyGxr 56mNCUOK+SGIC1gRwIelB5B0NpF+Gk+B1pxCux1eUZ5LNmS3nNgv65bzg5RFwZsMoUe3 e6TqqfmizVBEtLA74PA4+7eKomwtY/bHRe0oqH+W8qaP/uqGMgfWwt1Gs5GFEQ7uwpra J5YilK1NuBK8uYmRxivdZBvTxy3YOfCZj4pS4vdWo2pLbl/HBdlgq7QWwqt7Mb2aQsD7 DFdw== 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=kF6Mh7zBGTmZcZ4fgLRLs/sAGNyKsmZ+y/S5TzPnCVo=; b=kRYLOlQZqV/XiVpnFqNuys6bZ1yClkiYl973ydmnx8sSBymA0dMoZfmQuFds3kkwZG +4t+3nzp3kh4Cg+wx5eCw8+E186dcRp2ofzdlcWjFz0TNV+EKOcQKrZvoEjw7t/CSSqb JeMuI2WMrYLGZP1fhiRSF2z/97JA9dk9qC/CD8lc1n3YVcKKfuIEQvH0h8XpkpKtLs5b TmLah1vsbM1gZi4Xd57w5nKEf2T27P6rH5QIzlVYfvY+HkF7z2s+DjFdONu1K/delAHx Em0ARs+G9JhL/Cp5PmW4WwUeK3Y2jOQtzY5S2ulet5FtKrHQ0F6Hk+UYmp2XOZQSjred UARA== X-Gm-Message-State: APjAAAWxgzU6VXkBwFS6L/1BRVRMBhptN289CYzXAQjJJ7uRTi0WUQ1N rKA+MXCmUz7AJWcmuV9WVlpzyILzaGDhcww7wjE= X-Google-Smtp-Source: APXvYqwVlTyd+Vc9mJw1+UDOUusB9UMe2sc+Ocgyp9JXfmEBgx+ZJAjk22A2rOyzNlAUnhKerjqPwNWhZgMQZNXPWwQ= X-Received: by 2002:aca:4302:: with SMTP id q2mr218046oia.173.1571954580395; Thu, 24 Oct 2019 15:03:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 25 Oct 2019 05:02:52 +0700 Message-ID: To: Ken Stanley Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005e186d0595af3252" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] anti-coalescing-operator From: webdevxp.com@gmail.com (Kosit Supanyo) --0000000000005e186d0595af3252 Content-Type: text/plain; charset="UTF-8" Hi Ken `|>` is not something new it appeared in many languages long time ago (in some forms). JavaScript also has a proposal of it. And PHP someone has already proposed one. https://github.com/tc39/proposal-pipeline-operator https://wiki.php.net/rfc/pipe-operator Cheers On Fri, Oct 25, 2019 at 4:53 AM Ken Stanley wrote: > > On Thu, Oct 24, 2019 at 5:19 PM Kosit Supanyo > wrote: > >> Hi Ken >> >> I totally agree with Andreas especially: >> >> One purpose of the operator should be that you don't have to repeat >>> the variable. Here you do, e.g. $_SERVER['fname'] >> >> >> But if this operator provide some way not to repeat the variable it will >> make sense. For example: >> >> $_SERVER['fname'] !?? $user->setName($$) >> > > I asked Andreas for their opinion on why this is bad in this context? > Especially since if I were to use a traditional ternary or if condition, > then I'd still be repeating the variable. > > >> >> 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'm more interested in having a negation operator for the null-coalescing > operator, especially since cognatively it should be easy to discern what it > does. I've personally not seen |>, and I'd be confused as to what it does > (e.g., is it a bitwise OR on a greater than comparison?). > > Thank you! The idea of $$ is neat, but not quite what I'm trying to > achieve here. If anything, wouldn't that facilitate a different RFC? > > - Ken Stanley > > --0000000000005e186d0595af3252--