Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126366 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id E7FBE1A00BC for ; Mon, 10 Feb 2025 10:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739181711; bh=bD/l+vNFVH7LTZqixZulyN2ozAsmjoxdkZhE7yoNvok=; h=Date:From:To:Subject:In-Reply-To:References:From; b=cwBH4qRDxmoLkK+PihOUwJ62vLE27qZHykH6WWV1gELSWokv3SNhBa1U8C0xOuBI5 1QH/ku3NfPGcNq11nZ2PWsWZ3YJ5XnnGxAniMkcgNBXrBJjAXL+RJQCFFlZNoGjdBI wq92y73DXZX062KX2WO24vl4Z/5lwZwcailpyvIKJAQWHhFQlYnzcP4d4iDXesOHmx tUnkUL6qgPDNHQ5a8OLowt3mjzVp8eIe7TxMIj7XrXNRn23DvDUyC48fOR6JXY5U3i 7ghGj/XFdeUXL+JK5Z3hPcVx8udWqOaB4x4TUp/6crcJDWvA2CTZZW84Gn2QdJ5B9S EIkL5X5J7dQ8g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0452818006D for ; Mon, 10 Feb 2025 10:01:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 10 Feb 2025 10:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1739181872; bh=uvq5W2pcx5w62/pz3K1PT/9r7OtgQEuU6Iv/kGlWrVE=; h=MIME-Version:Date:From:To:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=PFte8EIDUx8R3vn3mHumf9TzxzHjxdgaPqZYUmS3bfk/rP5gdzI9qLrvpsvvo56WK 8IDvvKoZTyjKunltGwPbUpRBf+er7EUwgInqVehzXzvYG9bb9NVM5i729nHTTOyVlB JeIwTc63VvKvMdEEgxzUBIXndLo140pd+yH7QQ6m2lBP8roadFBH3Kto6wztJGSg5J HWkW+vRMjU9NgQ/uDKCbkpopduo3Bcn91mONFJsV8WFXwnjlG7+iiWrWXIiJiSH5QG R5HiKaZK8GYoAOYfs24yIG3eIFcRSshH9+hn+owxHhMMX5LfhTUDXzcPeJWImNdpVn 16qEie/26obSw== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 10 Feb 2025 11:04:32 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) In-Reply-To: References: Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-02-07 05:57, schrieb Larry Garfield: > https://wiki.php.net/rfc/pipe-operator-v3 After also having taken a look at the implementation and then the updated “Precedence” section, I'd like to argue in favor of moving `|>` to have a higher precedence than the comparison operators (i.e. between string concatenation and `<`). This would mean that `|>` has higher precedence than `??`, but looking at the following examples, that appears to be the more useful default anyways. I'm rather interested in handling a `null` pipe result: $user = $request->get('id') |> $database->fetchUser(...) ?? new GuestUser(); Than handling a null callback (using the RFC example, because I can't even think of a real-world use-case): $res1 = 5 |> $null_func ?? defaultFunc(...); To give some more examples of what would be possible without parentheses then: $containsNotOnlyZero = $someString |> fn ($str) => str_replace('0', '', $str) |> strlen(...) > 0; Which is not particularly pretty, but appears to be more useful than either passing a boolean into a single-argument function or piping into a boolean (which would error). Best regards Tim Düsterhus