Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115724 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98431 invoked from network); 14 Aug 2021 14:09:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Aug 2021 14:09:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E4E16180088 for ; Sat, 14 Aug 2021 07:40:49 -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.7 required=5.0 tests=BAYES_05,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-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 ; Sat, 14 Aug 2021 07:40:49 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id y34so25594432lfa.8 for ; Sat, 14 Aug 2021 07:40:49 -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=bfyQmc1MDeZrGCnrYLycbp4LPGOdty+eOiKl0cRq+T4=; b=gypHsMHGRBK+THjdEvAbFmio7ar5RekDGQRMW/5A0GVQKabh+pgYKD/OjKuRv2eVVL 9AVl3lgiuj1thRjbaX5fJ2EYgHc/fuvl6ffwozi1N++AUEErxAveQKWaT2l+4YrffsqL ojNfHTXdpedVj21TjsZuontZRwQLeQJICb62KIMuSUPNJStJSk/mY9Wi8Gg1IdzCEyVN RFVLGtSvk9JGXlCXKzxYuH0yNn17cpbFZdBa7mKLFfpx++hNzrtupA0q673U1POcoeVx jHCmqgfciHrWZaTc7I4Ffc0bTazuSHbxa/w+35gQakDKkdHZQ8p7SEqhX5uPiO9CDWlP JPyg== 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=bfyQmc1MDeZrGCnrYLycbp4LPGOdty+eOiKl0cRq+T4=; b=iAgstgNt75+XtJFEbWfhz1H4tcc4aEYJq9ZbNJrhXByR9JKrWYs/erdxP4aQjgMep1 B0hTxgX25tYME59bIpVh2kqZWQHPbOOnYSc1SadWjcQvNk/aa8l7a2dyHVOkUY1FYkjn EfQ/xUg37uOVd+B0UZlwd3TFZeFd7eZjUkC81g1TGIAfXjG6Xahc6XeJWyhthFNtTQTf Chclau3wSpUa1MhKSoUCYJzMcirDwDpLoBCXuJFnpu/Gv7HYaTKNxd7XEyaczS6rFFkO 1MGlfpDsqkDrHaI4jE1wFodAcmljOdxqJViLwEJZWNVwr/x/bAMJKuAtLcPVmgPlJ3FB I6oA== X-Gm-Message-State: AOAM531gkQS3ZgY2otQVkY5PUx31EEJYGd4I/SQOw1I5s444MqueC7m9 zl+ZqMZXN+ga+mi4NTDBTYkFZNSXZfIn8wjk3oNGCPNXqY0= X-Google-Smtp-Source: ABdhPJxXUAz3VtM93JivTsQNP3vVGWeIpCR7tbbY9ttptbQtw9gWWXNMVZnvy75jF9dVKlZcwBvjAQErIPkzPC20ku0= X-Received: by 2002:ac2:41c2:: with SMTP id d2mr5344320lfi.241.1628952047992; Sat, 14 Aug 2021 07:40:47 -0700 (PDT) MIME-Version: 1.0 References: <64b3800a-c54e-c1cc-8bab-bc503a969c37@allenjb.me.uk> In-Reply-To: <64b3800a-c54e-c1cc-8bab-bc503a969c37@allenjb.me.uk> Date: Sat, 14 Aug 2021 07:40:43 -0700 Message-ID: To: AllenJB Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000002d45d505c985f43e" Subject: Re: [PHP-DEV] [RFC] Never For Argument Types From: jordan.ledoux@gmail.com (Jordan LeDoux) --0000000000002d45d505c985f43e Content-Type: text/plain; charset="UTF-8" On Sat, Aug 14, 2021 at 7:01 AM AllenJB wrote: > > Whilst I understand there's a historical aspect to the keyword naming > used in this RFC, as a PHP developer, I think the use of "never" here is > going to be confusing to people when considered along-side the never > return type. > > I think it would make more sense to change the keyword for this RFC to > something else such as "any", "unspecified", "unknown" or "specify". > (Whilst "nothing" might also be considered given its use in other > languages, I don't think the meaning / purpose is that clear). > > This RFC only considers this feature for arguments. Why is it also not a > valid feature for return types? I think it might be useful for abstract > classes and interfaces (for example, the Iterator interface) to force > implementers to specify a return type for certain methods whilst not > specifying anything about it themselves. > > Never is treated as the bottom type for the purpose of Liskov substitution already with its use as a return type. The exception to this in its use as a return type is that it isn't treated as the union identity in the return type. However, for LSP never is the bottom type when it comes to return values. It would, in my mind, be highly inconsistent to have a different bottom type for return values than for arguments, so personally I am very against using a term other than never. As mentioned in the doc, I wasn't able to find a single existing language that has multiple bottom types. If anyone is able to provide an example of this, I would appreciate it. Never is the most common bottom type in other languages from the brief survey I did before putting this RFC together, with "nothing" as the second most common. Return types are covariant with inheritance, not contravariant. The return type equivalent from an inheritance perspective would be "mixed", as it is the top type and is a supertype of any type in PHP, allowing inheriting classes to narrow the type in any way they wish. The main difference is that mixed is a valid type at runtime for values, since it contains all valid values. Meanwhile, never contains no valid values, thus forcing type expansion upon inheritance. I can see your point about how it might be useful for interfaces to require an explicit return type of their implementers, but that is a bit more complicated of a change (and a more breaking one), and the point of this RFC isn't really to reorganize the entire type system. To retain Liskov substitution, the type to mirror this behavior for return values would be mixed since that's the top type, and changing mixed so that it required an explicit type of all inheriting classes would break quite a bit of code. This RFC as it is written has no BC breaks. Jordan --0000000000002d45d505c985f43e--