Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116205 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82837 invoked from network); 4 Oct 2021 07:25:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Oct 2021 07:25:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD44E180538 for ; Mon, 4 Oct 2021 01:09:29 -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 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-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 ; Mon, 4 Oct 2021 01:09:29 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id r18so61347089edv.12 for ; Mon, 04 Oct 2021 01:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ui2m0YUA89gdAIs4vtOwMPFzcOAval3UCArK2CKGTmY=; b=Qu6bG/v4qr0nv9IKJs+416XrK2Er19zxdxC8N3/zCIu7cZ/o1wa3FRDbInCGkKRJoa 1rG68rDhXLURNa1cv3leWBnDXcnPR9FUnoXu9v260E663iYHi5aWnvUGYFvY7H+9r9pY yLmxZ4Jd760UsCMLvW8NZU7b8vMp04Lg7rNlwOFV5j2Wj3Rdr7gmi1kF9yGOcNCjIBey sQS4uFgjSmc4xJ24Vz3Y2immunIz4MYGQsQ2wsu7xT8gmbuQP13pcnbUO32j/6sbTbPu Ugw2EANi/uC6yTq8gdgoQcN5tiJbpW9bMNrES6427TocW27Z+QKPP4vHzBYiBFdaiFPa imig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ui2m0YUA89gdAIs4vtOwMPFzcOAval3UCArK2CKGTmY=; b=vY3n9CFTAHe2+/oJh+nTT3zthlEz+6XVKrSWFuxKT4J72ap3xKYJfqcXgaHI9Bw/BE dNTVCQwTSXGlzD1zvso7CXXH7Bjhxi/bI7GK0qzJyWfwuWVh6WqbplaaG9imqIcI36ah KPzA6UPDljUoiduqXemL9hGWrkbRtVgqPmI6s4DVzCWgM9+bQ8OR2Hib3uXhrEtJ8WH0 z5hF4BoJyj6NZbgrplmFak6oMLtGSGqh5LtRinQosq9SlbvWzqdqlHQ/GXqEeargivnc mTyNW5VKJ3FDCCNlJMn2pXJ1mFcmqwAe+N6CNBXux9pDymOloXmokHEEz4n1Pexg673t 3P0w== X-Gm-Message-State: AOAM5301LMeUaBF3n4hibgzSh6G5ns3HKZo54ZRJgw7H4MSbV/QknDt1 Cty+Uk/yb4zTrpCtNxZK0Uj7X1njRBcaF3mMyyFaR51PWhI= X-Google-Smtp-Source: ABdhPJy79mNzoNoYepnLqPL1Z4a1bEVzS+DzT4fWtsSLQIjjl5kWDrYnXiwwYHQ7l5CW1iZTr5/d2ZgZIxYuJPIkomo= X-Received: by 2002:a05:6402:5191:: with SMTP id q17mr16735073edd.332.1633334968068; Mon, 04 Oct 2021 01:09:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 4 Oct 2021 10:09:12 +0200 Message-ID: To: Levi Morrison Cc: "G. P. B." , PHP internals Content-Type: multipart/alternative; boundary="000000000000922f5805cd826e36" Subject: Re: [PHP-DEV] [RFC] Allow null as standalone type From: nikita.ppv@gmail.com (Nikita Popov) --000000000000922f5805cd826e36 Content-Type: text/plain; charset="UTF-8" On Mon, Oct 4, 2021 at 5:33 AM Levi Morrison via internals < internals@lists.php.net> wrote: > On Sat, Oct 2, 2021 at 9:07 AM G. P. B. wrote: > > > > Hello internals, > > > > I'm proposing a new RFC to make 'null' usable as a standalone type. > > > > RFC: https://wiki.php.net/rfc/null-standalone-type > > GitHub PR: https://github.com/php/php-src/pull/7546 > > > > Best regards, > > > > George P. Banyard > > I don't see the word `void` in the RFC. I think there ought to be > something said about how naked `null` is different or not different > than `void`. > Right. To quote the original union types RFC, this was the motivation for the current limitation: > The null type is only allowed as part of a union, and can not be used as a standalone type. Allowing it as a standalone type would make both function foo(): void and function foo(): null legal function signatures, with similar but not identical semantics. This would negatively impact teachability for an unclear benefit. I'm not opposed to making null usable as a standalone type though. I think the fact that a "void" function must use "return;" instead of "return null;" and a "null" function conversely must use "return null;" instead of "return;" will probably be sufficient disambiguation. If we make this change, I would however suggest to also support "false" as a standalone type. I think this change primarily has benefits from a typesystem completeness perspective rather than a strong practical need. From that angle, it would be nice if all types that are usable in a union are also usable as standalone types, rather than shifting the special case from null to false. Regards, Nikita --000000000000922f5805cd826e36--