Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115572 Return-Path: <mike@newclarity.net> Delivered-To: mailing list internals@lists.php.net Received: (qmail 47562 invoked from network); 24 Jul 2021 04:35:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jul 2021 04:35:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E970A1804D0 for <internals@lists.php.net>; Fri, 23 Jul 2021 22:02:03 -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=-0.4 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: <mike@newclarity.net> Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for <internals@lists.php.net>; Fri, 23 Jul 2021 22:02:03 -0700 (PDT) Received: by mail-qv1-f54.google.com with SMTP id s14so2400466qvm.4 for <internals@lists.php.net>; Fri, 23 Jul 2021 22:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=HwRoy3mhtRFvnFncwemkhWpuZFGz2VJT1/lGAWQ7QLk=; b=YpwQQXAjrYEYg0em0ZS3e9bxHj8AMbGdUTYvsXGlaPuubidV0MH0nFQmE1vUEOtPAG ewZB0ad/ZqT6XYME90DXrFv52IupEvYCkVZYKFZSnVDG6Zg/qIUDrfyOCa2nmpeyuA9M bewD56ihnoqc+CHRipwver0XuxdBeMG7lMTjMizMB7IM/nRyHQ3wQwhueWA/I+qRTfQY Cn8dEVixpbPDaduW2dUSBkcXli55s/ubCuJvxb6YbkeJZNZgZuU8l2B6IIN3tD0BKTIb WNPsZCFqVKF8+PqJ74C6W3r34TNyI8sucRThD8vQpSztlUWyQ1ENpLtGQSu7WmeyHLVv GgqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=HwRoy3mhtRFvnFncwemkhWpuZFGz2VJT1/lGAWQ7QLk=; b=KyxhTMjwNojQGWQhNsrgULsyXeYY2wRP+67P5f2PHMk0/KnppcvFtfvbZHSy5ru7YS InbPSLARqSbhgW2VcqtNGKCZYE7a+S7wQLHjeQOaWOwbrCY2/K5l9qWdVOFexvDobznF 2An0zswjFLceQxUHCVgVlMj3Zftw1kJIZoEdtjWkfM1q+3AJm+UBVABYaZvsQuPZX9N8 x9DIkB6veSHDFMmY0eY4C8rOskKJT2W2OhcsVZBWiXCE24qWFFsjloSLaRxujmv0tFB0 WDLE+X9AW0ScO8tSslw96AlE3YgIziAk6NpiWBF8U7KPtq+yWvfBwzJNhjBuvx9yMnGl zFpw== X-Gm-Message-State: AOAM532AaDSHElcfyQUFU2peO6VwW9/I+9J3d7t1l+yDee+Zy5yK53ZN D/I5KPt/Nzl0S5MLk/5iwFoE0g== X-Google-Smtp-Source: ABdhPJzH8qQVrN8gZBgWSY0OT9p2avSGqM8ZjQ4uH8s4vs5uWfdzcBuRjgioOe7+sg8pYP8DRBILfA== X-Received: by 2002:a0c:f084:: with SMTP id g4mr8124078qvk.52.1627102920301; Fri, 23 Jul 2021 22:02:00 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id s3sm12353549qtn.4.2021.07.23.22.01.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jul 2021 22:01:59 -0700 (PDT) Message-ID: <94F0E6DA-8C69-402D-B6B2-5EBDEB6638FB@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_B9CD5E51-1AE7-4BE1-8D39-0F25EEC1964F" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Sat, 24 Jul 2021 01:01:58 -0400 In-Reply-To: <43D8F75F-09B0-4AE4-A9EB-8775E231B367@gmail.com> Cc: Nicolas Grekas <nicolas.grekas@gmail.com>, PHP Internals List <internals@lists.php.net> To: Tobias Nyholm <tobias.nyholm@gmail.com> References: <CAOWwgp=B7-AvMao0POCF_h_A3A4voHNA_BsjfonBQ8yDHb0v-A@mail.gmail.com> <353F9140-7E59-4CD4-95D3-9BA8F9CA6C29@newclarity.net> <43D8F75F-09B0-4AE4-A9EB-8775E231B367@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Nullable intersection types From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_B9CD5E51-1AE7-4BE1-8D39-0F25EEC1964F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 24, 2021, at 12:42 AM, Tobias Nyholm <tobias.nyholm@gmail.com> = wrote: >=20 >> It seems this RFC is actually trying to accomplish two(2) things: >>=20 >> 1. Add typehints for nullable intersection types to PHP. >> 2. Get PHP to support a preferred syntax for type-hinting nullable = intersection types. >=20 > Yes of course. You cannot really do #1 without #2.=20 >=20 > I agree with Nicolas that `?X&Y` makes more sense. You add ? before = the type. If the type is scalar, a class or an intersection type should = not matter. But I hear some technical arguments from Derick so I won=E2=80= =99t argue against that.=20 >=20 > Im fine with the syntax: `X & Y | null` > I don=E2=80=99t think parentheses should be required. =46rom a = mathematical perspective you want to add parentheses when you want to = override the operation order. If you remove the parentheses and the = expression has the same order of operations, then the parentheses is = clearly not needed.=20 >=20 > @Larry makes an argument to keep them:=20 >=20 >> Requiring parenthesis now leaves the option open in the future to = make them optional when doing full mixed types. >=20 >=20 > I don=E2=80=99t understand why we should require something that is not = needed simply because it would give us an option to remove it later=E2=80=A6= Could you elaborate why this is important? (Im probably missing = something) The difference is if we make the decision to use the `?X&Y` syntax and = we later realize it was a mistake then we are stuck with it.=20 OTOH if we use the (X&Y)|null syntax and later realize it is okay to = also allow `?X&Y` PHP could later be changed to allow it. The later is the choice that manages future risk better. >> Given both of these sets of assertions I would ask the RFC's author = and proponents what would be a worse outcome? >=20 > I don=E2=80=99t see how this question is relevant. We are not seeking = compromises at the moment. We are seeking the best technical solution to = a technical issue.=20 If you are not willing to compromise you will probably get nothing. It is relevant because I was trying to get you to ask yourself if you = would be happier if you get half of what you want rather than none of = what you want. =20 Because there is a very real possibility you will get none of what you = want if the RFC requires the syntax so many have objected to. BTW, I do not have a strong opinion either way, but since I see than = many do have a strong opinion I was trying to play arbitrator between = two sets of people who each have very entrenched opinions where their = opinions are in conflict. If neither side will budge, nobody wins. =20 >> o, the entire discussion has claimed a "need" for nullable = intersection types but AFAIIK they have been presented in completely = abstract terms; i.e. no one has presented any real-world scenarios where = they would actually use nullable intersection types. =20 >=20 >=20 > The =E2=80=9Cneed=E2=80=9D is covered by the discussion about PHP 7.0. = See this post as an example: https://externals.io/message/115554#115563 = <https://externals.io/message/115554#115563> That message mentioned the need in abstract, but it did not provide any = real-world examples. It claims that there were real-world examples, but = did not show any. =20 That message was also not part of the RFC. Listen, I am trying to help make the RFC better to improve its chance of = passing. If you don't want that, then I will just demure. -Mike >=20 > =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94 >=20 > When reading my message above could make it sound like I am = pessimistic. That is not true. I am excited about this change and I am = happy PHP has a long feature freeze so issues like this can show up = before the release.=20 >=20 > Regards, > Tobias >=20 >=20 >> On 23 Jul 2021, at 20:53, Mike Schinkel <mike@newclarity.net = <mailto:mike@newclarity.net>> wrote: >>=20 >>> On Jul 23, 2021, at 5:58 AM, Nicolas Grekas = <nicolas.grekas@gmail.com <mailto:nicolas.grekas@gmail.com>> wrote: >>>=20 >>> Hi everyone, >>>=20 >>> as proposed by Nikita and Joe, I'm submitting this late RFC for your >>> consideration for inclusion in PHP 8.1. Intersection types as = currently >>> accepted are not nullable. This RFC proposes to make them so. >>>=20 >>> I wrote everything down about the reasons why here: >>> https://wiki.php.net/rfc/nullable_intersection_types = <https://wiki.php.net/rfc/nullable_intersection_types> >>>=20 >>> Please have a look and let me know what you think. >>>=20 >>> Have a nice read, >>>=20 >>> Nicolas >>=20 >> It seems this RFC is actually trying to accomplish two(2) things: >>=20 >> 1. Add typehints for nullable intersection types to PHP. >> 2. Get PHP to support a preferred syntax for type-hinting nullable = intersection types. >>=20 >> Further: >>=20 >> A. There seems to be consensus on the value of #1. >> B. There seems to be consensus on using a syntax with parentheses for = #1.=20 >> C. There is a lot of pushback on #2. >> D. The desired syntax in #2 would reduce future flexibility, as Larry = Garfield commented.=20 >>=20 >> Given both of these sets of assertions I would ask the RFC's author = and proponents what would be a worse outcome? >>=20 >> X. Getting typehints for nullable intersection types added to PHP, = but not the desired syntax? >> Y. Not getting typehints for nullable intersection types added to = PHP?=20 >>=20 >> When answering please consider that #X is the outcome that would not = preclude possibly getting #2 at a future date. >>=20 >> --------- >>=20 >> Also, the entire discussion has claimed a "need" for nullable = intersection types but AFAIIK they have been presented in completely = abstract terms; i.e. no one has presented any real-world scenarios where = they would actually use nullable intersection types. =20 >>=20 >> It might be helpful =E2=80=94 or at least it would be for me =E2=80=94 = if the RFC could add two or three real-world example use-cases where the = author and proponents would actually like to use nullable intersection = types in their future PHP code. =20 >>=20 >> #jmtcw >>=20 >> -Mike >=20 --Apple-Mail=_B9CD5E51-1AE7-4BE1-8D39-0F25EEC1964F--