Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120855 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38287 invoked from network); 20 Jul 2023 20:02:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jul 2023 20:02:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0ECAD180382 for ; Thu, 20 Jul 2023 13:02:01 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 Jul 2023 13:01:57 -0700 (PDT) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-55ba895d457so652775a12.0 for ; Thu, 20 Jul 2023 13:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689883316; x=1690488116; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ed4vpSylukp2jHJMfQhwQHqW4dRoUFILvW8njB5DMO8=; b=fEy4UKN4Yj8F+O/4kYisgs1QcOVmlYnvgQPtKL07TA/jDk9R+S+SvKlmvlcS8eROdx WcCVWA6WR7YeHIg3OeSz12BLsX4WJHMeveCwalnVYPHmQLHfCrUaP4aRB+exWJEovoQE 0YBNKMkG2AzadiAwtZZgbCeJQM3lt6e5IwJ3tmzaGIOEFfBL96ieh/3Kf09AIuYodLK3 PkCqfBm0OaDx1mNdpCT96+wEk9KkIq7jxshDEH3FcNTCnQ6tQ9ARENwyNLlnKEG5if/U cWHrAUrvcvGsyAcnj2+mUXNy+M2rWwJDxy8VLLsKs4Y9SeOeI/7YqT071R1nsGLkz8PH qiSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689883316; x=1690488116; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ed4vpSylukp2jHJMfQhwQHqW4dRoUFILvW8njB5DMO8=; b=BIDckcJmWUiPnu4CCyR4v+mEhS5LeyZUNzkEnthbp3+m0tvhOx4X/wkqHJvB3kzvYC XQSqIBVNO+VCV0nPNHvgTGUdVZSXQ+YKPaRqdNcj1UH3I1aBXlJDBh6/9MflfWsRvBz0 x/VxByL3KFbxLZHUM/o+olJnXGLoeR5DfA0pgruYhodL2dmtnrHo4ojrVSJ8U0HOAKPe /vkcHRVaQVZhUPRmjctKKTHunYQTLNDdkHSVUqx0KaxsKHlSxQToZS5GQOcV2pgKcrbD COaj0WId6fVT/m1XblFcW/oPjV9DdMGtK9EBX8xGRfg1Pe0vjk73ViqPCJ8Laj11drlo zUKg== X-Gm-Message-State: ABy/qLbOmbWsy3E0ScMb1PXBHWrKzM3BWsiZZUBrSpmQTeRMW5CTT0Sp wfXzHXS1pcLEJ0Myp/67aNXEautGzkncPT134fA= X-Google-Smtp-Source: APBJJlEWMy6IRILlkfPPZkUZul3uevWpVQymOwW7IsiJ1fPg1kBZe6IxlExRNF2GbzUKxysKgY+6fkmfNwle3QAkwBc= X-Received: by 2002:a17:90a:fe8c:b0:263:f5a5:fb98 with SMTP id co12-20020a17090afe8c00b00263f5a5fb98mr259610pjb.28.1689883315587; Thu, 20 Jul 2023 13:01:55 -0700 (PDT) MIME-Version: 1.0 References: <8055b366-32f1-4d2c-85d0-0cf665e6c8d3@app.fastmail.com> In-Reply-To: Date: Thu, 20 Jul 2023 13:01:43 -0700 Message-ID: To: Robert Landers Cc: =?UTF-8?Q?Olle_H=C3=A4rstedt?= , someniatko , php internals Content-Type: multipart/alternative; boundary="000000000000bcd0ba0600f09e26" Subject: Re: [PHP-DEV] pipes, scalar objects and on? From: jordan.ledoux@gmail.com (Jordan LeDoux) --000000000000bcd0ba0600f09e26 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jul 18, 2023 at 8:05=E2=80=AFAM Robert Landers wrote: > On Tue, Jul 18, 2023 at 3:18=E2=80=AFPM Olle H=C3=A4rstedt > wrote: > > > > 2023-07-18 14:48 GMT+02:00, someniatko : > > > I am glad this topic arose! I was also planning to write on this topi= c > to > > > the internals mailing list, but have abandoned this idea, because I > feel it > > > might be inconvenient for the real active PHP developers on the list = to > > > receive too many emails from the people which don't actively > participate in > > > the development itself. > > > > > > My interest in the pipe operator might seem a little non-standard - > > > basically what I'd really want to see is a **nullable** pipe operator= ! > > > > > > There is a popular library github.com/schmittjoh/php-option, which > has 250 > > > MILLION installations. Basically what it provides is a class-wrapper > of a > > > value of lack thereof: it's either `Some` or `None`. I also > maintain > > > a similar library > https://packagist.org/packages/someniatko/result-type > > > which fixes some shortcomings of the original one related to the stat= ic > > > analysis, but this is another story. Basically what the stats tell us > is > > > that such stuff is popular among the PHP community. > > > > > > In my eyes, it is actually semantically equivalent to the nullable PH= P > > > types: `?Type`. And some operations provided by the lib, are actually > > > covered by PHP itself, which has multiple null-friendly operators: > > > `$option->getOrElse($defaultVal)` --> `$nullable ?? $defaultVal` > > > `$option->isEmpty()` --> `$nullable =3D=3D=3D null` > > > `$option->getOrThrow(new \Exception('blah'))` --> `$nullable ?? throw > new > > > \Exception('blah')` > > > > > > I'd like to use the arguably "more idiomatic" native PHP nullables, > rather > > > than a foreign-feeling userspace construct, if they were more > convenient. > > > > > > But there is a very important operation, `map()`, which is > unfortunately > > > not covered by the native PHP, which is `Option::map()`, and here is = a > > > real-world example: > > > ``` > > > return $repository->getById($idFromHttpRequest) > > > ->map($serializer->serializeToJson(...)) // only executes when th= e > > > Option is Some, not None > > > ->map(fn (string $json) =3D> new Response(status: 200, content: > $json)) > > > ->getOrElse(new Response(status: 404)); > > > ``` > > > > Ehm, wouldn't that be the same as a Pipe class that's configured to > > stop on null? > > > > public function getThing($id) { > > return new Pipe( > > $this->getData(...), > > $this->serializeData(...), > > $this->mapToResponse(...) > > ) > > ->stopOnEmpty() > > ->from($id) > > ->run(); > > } > > > > Wait, are you using map() for arrays or not? Looks like not. > > > > Olle > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > > > > I might be venting, but, I wish the operators RFC had passed... > I don't think I will re-propose it with the current set of voters tbh. The main people who contribute to the Zend folder (the core engine/compiler parts) were highly skeptical of it, with at least two telling me flat out that they would vote no even on a hypothetical perfect feature design. Very few contributors actually touch large parts of that area of the engine, so most voters tend to take the opinions of those 5-6 voters very seriously on such proposals. As I don't think it's possible for me to convince those 5-6 people, I don't think it would be a good idea to re-propose, because even if I did get a 2/3 vote on it, I feel like the people most responsible for helping me maintain the feature would not be very happy/willing to do so, and that would probably harm the PHP project in other ways. Jordan --000000000000bcd0ba0600f09e26--