Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122487 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 qa.php.net (Postfix) with ESMTPS id 51B651ACEBF for ; Sat, 24 Feb 2024 16:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708791634; bh=CrcWKklb7ijuXED94N9CluMOe7wY3myDaIxsACPsQ5Y=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=SnfEDTjl7gID62adFu2JPF+Z15Ls6+BFZRBLK23plXI3NaEyzXB/CYYk/izNLJWmO vjgB1ssnOdKjTbKylujGl81eqR/zsujVVx8tAniEhBvrTaZSis9xgNBg+vOLI2S98V ZtUWYtWZRn0+B5Q4ZJcREzxVefKjYEgkAA2VwsyrCtoVkquQOlooFTwnbFCU4IENGm xVuhCEIyMKzIIyT9rcJRZ2evPUFRTLHtrh1+Yp2Ifn+aE5gGWaOTnTvEYzpfIKBZVg DMhd9+q4YSMF38JkaUuXtO5gPEzlAtfWQq3ghInZS8jkebbq1r13KYNOM8d4w9OA2g oC0BO8GQXGzhg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9E1318003E for ; Sat, 24 Feb 2024 16:20:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_PASS,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) (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 ; Sat, 24 Feb 2024 08:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail; t=1708791621; x=1709050821; bh=CrcWKklb7ijuXED94N9CluMOe7wY3myDaIxsACPsQ5Y=; 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; b=kDHidUThihFZjLnMCZoh9BXvNXUFK7aDbolMGK3crJnzT4BAbF1yoyDd1dtoCvH57 qg71h/2vPUqIaai6Y5VcguX45vgVCdsSv7Q4bSBET8EvQ0Hw3Wd6QehWITn7BC0ryN mP3wcY9py4rvuTydVCye7q7nzBEXtG4HnUpxiL31IUxSMwtUppNZ3uxSfvEKY/F8Bt vK8b/USSTXPEgYqPgmLTjoiI4X0J97zUOh3X41Fif6Nl7s4zsaSReV3r/ym8nKcCkt GL+pgdTI1ZhEFMQLVEfQIKuPa5CZIq7nMyJ+ukwc7DtDNxYlAaKusgNjmFLPpseAcm +w+qB3+0NgNmw== Date: Sat, 24 Feb 2024 16:19:56 +0000 To: Kamil Tekiela Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [Pre-RFC] Convert exit (and die) from language constructs to functions Message-ID: In-Reply-To: References: <65D94D20.6020702@adviesenzo.nl> <65D97FC1.2060203@adviesenzo.nl> Feedback-ID: 96993444:user:proton Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Saturday, 24 February 2024 at 11:46, Kamil Tekiela wrote: > I would actually be against this change. It's a language construct for > a reason. Functions can be disabled and overridden, but language > constructs cannot. Exit is supposed to end the script execution > without any hidden quirks. >=20 > I don't actually see any good reason to make it a function. You can > very easily solve your pet peeve in userland by simply wrapping exit > in a function. > function my_exit(int|string $value):never { exit($value); } > You can then pass this function as a callable, redefine it in a > namespace, and it obeys the normal function type juggling rules. >=20 > This is reminiscent of Python 2 -> 3 migration with the print >=20 > statement to a print function change. While you may think you see good > reasons to make this change, users may see it as trivial and unworthy > of all the fuss. >=20 > Unless there is some extremely good reason to make exit a function, I > would advise against doing it. I'm impressed by the fact that one seems to ignore what my first email says= . It can be a function AND NOT be disabled by the disable_functions INI setti= ng. It can be a function AND NOT be able to define a custom exit()/die() functi= on in a namespace, this is similar to assert() which is also not a language= construct (which _can_ de disabled with the disable_functions INI setting)= . It can be a function AND NOT have _any_ user facing changes. The PR is implemented in a way so that there is no BC break at all for user= land, except AST-based tools. And people have suggested a way to not break AST tools, by transforming exi= t; into exit(); at compile time. I also find it extremely weird that it is acceptable that exit() has its ow= n completely weird type juggling semantics that break user expectations, when it looks like a function. What is the reason to force users to know an= d learn this weird quirk about exit? Also, comparing this to the Python 2 to 3 migration with print is *totally*= disingenuous, you cannot write: exit 10; or exit "Hello"; if you do, you get a parse erro= r. I am not suggesting to make require, or echo, or print be functions as that= _would_ be similar to the Python 2 to 3 migration, and I agree that would = be a bad idea. This change just makes the language more consistent and removes one type ju= ggling context. I realize that I probably should have just spent time writing an RFC and do= ing the discussion directly, as I'm effectively laying out the arguments wh= y we should do this in an email. Best regards, Gina P. Banyard