Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113923 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97187 invoked from network); 1 Apr 2021 19:05:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Apr 2021 19:05:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 688E91804E2 for ; Thu, 1 Apr 2021 12:03:22 -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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 ; Thu, 1 Apr 2021 12:03:22 -0700 (PDT) Received: by mail-io1-f50.google.com with SMTP id k8so800074iop.12 for ; Thu, 01 Apr 2021 12:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=EptVaeSMnKe6Kpse/fmWqqvNNXsJSU2fNuimdNh3AgM=; b=KIbLI1nM13+MbyP7r9ZiVdL/QgMpq4PL3z4Hx6s+5qDhNcppO2py4GDmwaOJu6g9G9 YUuNPuyNdw2F/TS3QLu86B4JGK1qkwYtK30wgOPdr9TT8rm1A84fEbcMRJgcEPnTqBI+ C1rwtvEMGZtEiYPXHrJJ5YiyMQyjfvm2EBEiA= 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:content-transfer-encoding; bh=EptVaeSMnKe6Kpse/fmWqqvNNXsJSU2fNuimdNh3AgM=; b=MKZNf1t6Z6ZuO6nOtjp99gAzAjikDXaN0CWC4XyhkbVllgE8v8+FvcaVosffpPFl2B /GQ8gSfpT6nj7igXXOJXUJkB4DQaBXipDPo3a6rNXslSr0TRUK557hELSJ7gC+D8oeHP 5W/lfhfrbsGi7cxPO9NVSILxe0UgWXzEr2aon+ELKaoeKeJKJch5LMv4nB+LSG7uY/Cv LWsI3385RDapoMQIhuo+MRFT7KVE2vw5gOnSQlE3ckobJvetxNLL+r0Lyesk4ZDuSQZi Frf/kPakRSrGxBCOoJcYw026833GU4pLx8c3N4kgXobWH/A+7fCgcbhOEaGvtdm7eQib 2ITQ== X-Gm-Message-State: AOAM533KBZyGgKKGB9vsrTvaUyQvNtolI42/jShv65bK13fJ03mbQ9/p SI+1hT7myLN5JeCl/Iv12/x/WPFBDauXO6tJz4RO7iF2ixU5+Q== X-Google-Smtp-Source: ABdhPJzrCg2YutqUfCl/1Zz2SS5C9Td2QfxCUC7cy4OSghP+yNvT+lIjqHSiKSho4cGOOQ6cvyRqoYtFzpraiOlfmZI= X-Received: by 2002:a05:6638:218f:: with SMTP id s15mr9311569jaj.58.1617303801109; Thu, 01 Apr 2021 12:03:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Thu, 1 Apr 2021 13:03:10 -0600 Message-ID: To: Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] noreturn type From: internals@lists.php.net ("Levi Morrison via internals") On Thu, Apr 1, 2021 at 6:59 AM Matthew Brown wro= te: > > On Thu, 1 Apr 2021 at 04:56, Benjamin Eberlei wrote= : > > > This RFC is using the declaration of the return type, to specify that i= t > > never returns. As such noreturn or never is a keyword a long the lines = of > > public or final, but it is not a return type. > > > > I don't think the argument for potential optimizations in Opcache to > > eliminate dead code or allow IDEs to hint at dead code are valuable eno= ugh > > to justify this change. > > > > By this argument "void" should also be an attribute =E2=80=93 there's no = reason to > hint a value that's not being returned. > > You'd write functions like > > [\Void] > function foo() { ... } > > But we don't do that, because the wider programming language community ha= s > agreed that "void" is a type, and at compile-time PHP's engine can ensure > that "void" functions do not return a value. For what it is worth, it does return a value `null`, which has a type. Using "void" is outright wrong, a lie told because "we" voted it this way. Few people seemed to care when I brought this up, but null makes sense with union types, covariance, etc, which we now have. I'm still slightly bitter about this, in case you cannot tell. The [void RFC][1] said: > There's no precedent for it and the name doesn't seem to have been an iss= ue until now. This was disingenuous, as it disregards Swift and Rust, both of which use a unit type; they just call it () instead of null. These languages are held in high regard as far as mainstream programming languages go, but instead we voted to repeat the mistakes of C and company. I believe Python's PEP 484 for Type Hints was available at this time, and it uses None when no value is explicitly returned just like PHP does with null. But, we decided to do it the wrong way a la C. Let's please not repeat this mistake. For the record, in C this is an attribute (and non-standard at that!), not a return type, so this is a particularly apt comparison. Please, let's _accurately_ follow type theory and use a bottom type. According to the [data in Wikipedia][2], the most common names for the bottom type are: 1. `never`, used by Elm and Typescript. Note that in Rust the bottom type is `!` but spelled out in docs as "never". 2. `nothing`, used by Kotlin, Ceylon, and Scala. I do not care which name is chosen, but if we are going to have this sort of thing in the language, it ought to be a bottom type, not an attribute. [1]: https://wiki.php.net/rfc/void_return_type#why_call_it_void_and_not_n= ull [2]: https://en.wikipedia.org/wiki/Bottom_type#In_programming_languages