Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115684 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27951 invoked from network); 10 Aug 2021 12:09:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Aug 2021 12:09:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3739F1804DB for ; Tue, 10 Aug 2021 05:40:06 -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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 ; Tue, 10 Aug 2021 05:40:05 -0700 (PDT) Received: by mail-ej1-f46.google.com with SMTP id d11so10757710eja.8 for ; Tue, 10 Aug 2021 05:40:05 -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=OCppbWDE9MVuh9HxTjYYxqmf187eAgNpwkQ++xsOecU=; b=MQcTtwJ1BplNbbJkvBjItiPnP953tnRmaoGwVkxXR1PbzFk7zygtOYs+dmxExJF6j9 y0j46z9UYPfEwc6VyyV4zXuOjMo/T/aJqt+M6bclrZhbdrudy6e+8kj9fCkVoHq8MKZe t/AETpiTGHBsFWfCQNGIOeW3LVJM+kzH0TIka9GyXPC9dkUBhHH9KStqNYfrp09qhhX/ IFDnieKnIt799wS+DBIRz48CEHigdUkhP+WXDgQXLtLEOh9gsFB11luao1NxITKM/gqb npOrW7wKnJM6uaJWQtqBw76B06jYNlyOBeurLjEznfnE5XyrtJ0YmbgP8DlO3lCk3jWj HvWQ== 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=OCppbWDE9MVuh9HxTjYYxqmf187eAgNpwkQ++xsOecU=; b=pXUGqsmeoIAJkCF7rMrbq0wI5kC3Ic0QwrRDJBiE5TkVn6CRULV6JEhvKwaNWVuHlQ cXEVMcUQrygbTQwzqtGsHeuvAZSxnnwuD+qXxGRCpy5stZs+0wjXJ6czTatZ3/ykfCH0 QEe9Qclzo7VMFeFSkxwffo73IjP3ivvi5Pjcc7YhPTmhWfBBTUdesxGSnybYQCx/Jfbo 0IJhjkeA6iqIs8dfwPjoSPBxIRMccGKDBrklz11MqodOQzDWMCwe+znsZCH3E4ebGjSF nYYFwUQ4PjshUuv9Ht8BtMer+HFPlAvfUJguPruNCCVE8Ot014aCMTLZwCLDeFVZN8Ka j7Nw== X-Gm-Message-State: AOAM5320hdtKu9Gy6jpIlQzQlCX22iBiCp5M7Ct1QHQMPGX9Sr5/QYA1 Ft8QUe4fQLPR/jDZ7oyL8W3mHmvgEzQ8p3Hm0Lc= X-Google-Smtp-Source: ABdhPJwfXfyP85BEZLNY8YPnvqRIf6irWu9qaJJYs29SqwiNKlMSkCCJCZYhglGhQpOspGBg4idHdi+F7409Ve3Rj7s= X-Received: by 2002:a17:907:2595:: with SMTP id ad21mr26538815ejc.430.1628599198945; Tue, 10 Aug 2021 05:39:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 10 Aug 2021 14:39:46 +0200 Message-ID: To: Dan Ackroyd Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000bc14f305c933ccc8" Subject: Re: [PHP-DEV] Re: [RFC] Nullable intersection types From: nicolas.grekas@gmail.com (Nicolas Grekas) --000000000000bc14f305c933ccc8 Content-Type: text/plain; charset="UTF-8" > On Wed, 28 Jul 2021 at 08:29, Nicolas Grekas > wrote: > > Nullability is a special beast in PHP. We have a range of operators > > dedicated to it. That's also why I think it deserves special care, and > why > > I think it's important to have this discussion before 8.1 is out. > > Why does this change need to be done now, rather than wait for 8.2? > > I can't see a clear reason in the RFC and saying 'nullability is > special' doesn't seem a clear reason either. If you think you'll only > be able to use intersection types when they can be union'ed with null, > then ... just wait until they are? > I will wait if I don't have the choice, but as many others reported, the experience with 7.0 missing nullability was a pain. We can learn from past mistakes. In my opinion, we can do better than the "wait for 8.2" stance I'm hearing around and make intersection nullable - like every other type in PHP - right now while we first release it. More generally, I'm not in favor of shipping partial features based on hypothetical future improvements. We don't know the future. Eg type aliasing or generics are vaporware right now. One or both of them might never happen, for whatever reason. > Andreas Leathley wrote: > > Having one clear RFC voting option (with no > > secondary syntax voting option) also seems the most honest, as if > > somebody agrees that nullability would be useful but would only accept > > one syntax choice, that seems impossible to represent, necessitating a > > no vote on the whole RFC. > > I strongly agree with this. > > Having a situation where people will want to change their primary > vote, based on which option in a secondary vote is winning is a "not > good" situation. > > Having syntax for a type system be chosen by a popularity contest, > where many of the voters are not aware of the implications of the > choices is also not good. > I find it quite dismissing to refer to "voters" as a group that decides by "popularity contest" or that is "not aware of the implications of the choices". I do trust the voting process and I do think that the discussions we're having here on php-internals and related media are appropriate means to raise voters' awareness of the topics at a glance (I also think the voting process might be improved, but there's already a separate thread about that.) Instead of fearing others, let's discuss things and ensure we raised all points so that ppl can make an informed decision. After this discussion, I hope ppl will vote according to what they think is best for PHP as a whole, all questions included, and independently from the rest. That'd be the most honest thing to do IMHO, and the best for PHP (on this RFC or on any other.) RFC authors should be trying to pass an RFC they are sure is the right > choice, not leaving important decisions up in the air. > Because nobody raised any potential blocker with any of the proposed syntax, I'm confident that all voting options have equal future-proofness. The remaining is a matter of coding style preference. While as the author of the RFC I do have a preference for the "?" nullability flag, others have strong and different opinions about it. Since the primary motivation for this PR is to provide nullability for intersection types, I'll be fine with any syntax that is consensual eventually. > Larry Garfield wrote: > > Some other mechanism such as the sometimes discussed type > > aliases provides an alternate way to solve this problem. > > This is an important point and why trying to push changes to the type > system through after feature freeze is a bad idea. > > The example in the RFC uses single letter class names; in my > experience most classes have quite a few more letters in them than > that. Trying to use intersection types with realistic class names > leads to code like this, for a custom cache definition*. > > function foo(Get|GetOrDefault|Set|SetWithTTL|GetOrGenerate|Clear $cache) { > ... > } > > Which is pretty unreadable. I don't think I'll be using intersection > types much until PHP has the capability to compose types. e.g. > something similar to this: > > type SimpleCache = Get|GetOrDefault|Set|SetWithTTL|GetOrGenerate|Clear; > > function foo(SimpleCache $cache) { > ... > } > > At which point the need for being able to include nullability in the > intersection type goes away. You can instead use the existing ability > to indicate a type can be null: > > function foo(?SimpleCache $cache) { > ... > } > That's an excellent argument in favor of using "?" actually (syntax consistency and readability), thanks for pointing it out. I'd go as far as saying that type aliases should forbid making "null" part of them. That way, nullability would always be explicit in the local type, with an easy-to-spot nullability flag. So yeah....I agree that widespread adoption of intersection types > might not happen in 8.1 but that's fine, and better than possibly > implementing the wrong thing after feature freeze. > We're having this discussion to be sure that "wrong" won't happen, while the good will. And based on what was raised so far, I see only the good coming. Cheers, Nicolas --000000000000bc14f305c933ccc8--