Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127580 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 680C91A00BC for ; Wed, 4 Jun 2025 13:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1749042404; bh=6oX3LCRwbkXAO6E4vUPVKOmzX1esBTeNzo2NX4GUP7w=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=WQ0PV2dz1XJstTc5SKhy/XHY4lpS3lIVsJCqBuI1H2eWvAVc09D02k6uHEsad1kUp 9iAg2R1xQhnDzNkPZal9/ikVow76XgTJt48+JHO7Ub61HA8Adh2X4D3KCsGqinPf/B Q69PhCNt8fCRGVA5ONNMmMmBH2//SzQK77QZBlyxtC0V+as5xf3kZEiARYtMyxqVTG 2GPBSDfo3Wcll1gGGoANxh56X/rJjwVGHNfeQcEudd8YuiJivgIrSFEfRW/OkBRVv3 6cGkRrlDXovRU9CcGePQ/AovuVCWMci4TFgjjYR2nO39V3Oytok0jALOjOUNCkQlv1 uH0hKnIMOPp+Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 78308180061 for ; Wed, 4 Jun 2025 13:06:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-10627.protonmail.ch (mail-10627.protonmail.ch [79.135.106.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 4 Jun 2025 13:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail3; t=1749042523; x=1749301723; bh=KEgMzQNk/5a561mNsor+PdUl4LjsV9JxLW4uGUoqQD4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=MrN0GBtXifRHZaxAG2yHi1IcsQ/BWrj9oCg0scMM2F4HFC0wRu1HcJTiFriHM5dqo ReTSakN3bU2eAMmCWT7c8eKKZUlp0WUkRWiwFwqvsx0CjqG3paCd3WW1bdKkwHFM0S aQ5Y9XE4HRhOkQ4x+5BJ5P26R/wjfNV8TNjlsMp2NwlSxqE0gmRcyuAela5m9EnHQa ZmCneuZc0phZVX75VkbRDGC4q7DAW+BI6yDDMS9Ge/8GPUWQLkO/U8OvrPnwTYi1le m9gD1AOV0TOKEDc7/tFK5rlD3RsCsSNp1aa89n0F2lfteWvbYHyrwY2PNOW63LT3X7 5pMd1Pzn1c+Kg== Date: Wed, 04 Jun 2025 13:08:38 +0000 To: =?utf-8?Q?Tim_D=C3=BCsterhus?= Cc: Ilija Tovilo , PHP internals Subject: Re: [PHP-DEV] [RFC] Transform void into an alias for null Message-ID: In-Reply-To: <1549c650b0eb4ef61a03a16ecd652e45@bastelstu.be> References: <6Z2Ysh6MjYp1nyzuB0bTPJc5srObIcMRqt731JaQeXUJk1f_V_Yo2nRn8WvjI7er7pp7pIUE6WYl5pRwvYrtcrd07nCutyAqKPSsZHmrS-Y=@gpb.moe> <7yeVC5ZrSBpIklddJCWbIApB-mxRpBPasvWFIgoDeXZGXo_kbqdXAdNPEYoe0ajVjA1-P-w2d2JuDdYAN99BShDfnIPiuUqPuB_PbHEdeZ8=@gpb.moe> <1549c650b0eb4ef61a03a16ecd652e45@bastelstu.be> Feedback-ID: 96993444:user:proton X-Pm-Message-ID: d97a00cda3f1b7d731f497f1cf342b04370cf2e6 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Wednesday, 4 June 2025 at 09:50, Tim D=C3=BCsterhus w= rote: > Am 2025-06-03 17:42, schrieb Gina P. Banyard: >=20 > > A type system should be logical, and the fact that the top type (mixed) > > is not a super-type of all types doesn't make any sense. >=20 >=20 > I do not consider `void` to be a type per se, but rather as an indicator > for the absence of a value. Well we fundamentally disagree on this topic then, the RFC that introduced the void type [G1] used as justification for the na= me void: > The main reason to choose void over null is that it is the customary name= to use for such a return type. > [...] > others [PLs] (TypeScript, ActionScript, Swift) do allow void functions in= expressions, just as PHP does, by making them *implicitly return some unit= type*. *Emphasis mine* This reads to me that the authors know that `void` would mean "return unit = type", rather than "lack of return value". Moreover, another justification is: > There's no precedent for it and the name doesn't seem to have been an *is= sue until now*. *Emphasis mine* Which, IMHO, is not the case any more in that there is an issue now with a = split and nonsensical type hierarchy. > Basically the difference between a =E2=80=9Cprocedure=E2=80=9D and a = =E2=80=9Cfunction=E2=80=9D [1]. > That's why it makes sense to me to treat `void` differently from the othe= r types. PHP does not, like many modern PLs, make a distinction between a "procedure= " and a "function", as they are the same thing. In many PLs a function that returns "nothing" means returning the unit type= . And PHP's unit type is null. Making void and null isomorphic does not prevent people from using either t= ype name to communicate intent in their source code that this function is "= procedure" or a "true function". And if the point of void is for a function to say that it causes side effec= ts, then adding effect type declarations to PHP would be a better solution,= e.g. ``` function foo(): null!my_side_effect1|my_side_effect2 { bar(); /* causes my_side_effect1 */ foobar(); /* causes my_side_effect2 */ } ``` > See also: The `(void)` > cast which we decided to make a statement rather than an expression that > always evaluates to `null`. I do not see how this invalidates my argument nor support yours. Best regards, Gina P. Banyard > [1] https://stackoverflow.com/a/721132 [G1] https://wiki.php.net/rfc/void_return_type#why_call_it_void_and_not_nul= l