Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123438 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 6CB9F1A009C for ; Mon, 27 May 2024 18:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716833491; bh=GGT9ak+06sqASRO6ybS2nIbkcZcLWISbSv3M+l7UjJE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=IJ7Vrl985XUK/7DQhUPIlLIclBqP9rLt6DDOI9dArZvKajzEr8kaKetuUyb3Rb66R YIFlQyOxE+syVlhdKQUE0D0L9iqp/i+zKVn1dr/7HmVL3XIifv6PnQeOzCeO0SG5JD dnev2Hlz8CdBxkbvYJ5ZVnBJOfwz6HC1TjcK1njOpUqshMKRkGrj59QVg6bJDwTD5j yoZyGRPICx0j6wbjAhrPRjfnlS6neTtjy0wJ/ETNAMk3PqbRZLtASkDWsLkbR+Rha8 Iahml7y/mN+Ufo5S/rCumbR/GIfC2mpFBxi0t7RwWtDPR3kHqBxrFF3hYUrOiNRsTf 1bq7bFR/VNogw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C91D2180041 for ; Mon, 27 May 2024 18:11:30 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 ; Mon, 27 May 2024 18:11:30 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-529682e013dso13550e87.3 for ; Mon, 27 May 2024 11:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716833429; x=1717438229; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GGT9ak+06sqASRO6ybS2nIbkcZcLWISbSv3M+l7UjJE=; b=mrdUiY2+KM3jgKAdlm/cGjG3hTe+nDw6H+MwK+4tiU/lC4W7PVcg+2mYbKq3DSxxCs UlJ0Lc+M/YVEaf2yj6J6M4aB1zKDUCf0Fien/OnRNzpyniDPzVudXVoidWKjE1TtMm9B Dswp/+IpK+e5sdjxaTPQb/+u2Zfvj2RK1b1/DWckfRKFjmuSaQtTviiAcHy1JoT6AyoK tJVLLlwUebDweam3k/pmGh0KpFSU+snkh/erkBi8zAwmRTWoKeYzGdsBizq0hTljVY/t FWyiv6a+XwHxJPh3A/vUiAeLk/qUTGM4yE2Vn0jHeiB6L1j2BZkMtPB5isO1+jVdUDSY dmbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716833429; x=1717438229; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GGT9ak+06sqASRO6ybS2nIbkcZcLWISbSv3M+l7UjJE=; b=eAk3Pdg6deelmepbG8ohFfwZrW+VkaHy2x0CvHk7SctrHQhapLI4Z+Hx6xaS98xq2l WRgoDlAUpHuOiY663cVRSeCa+HsPhqAsNNLrzfKb/kWma1ycVHReF1o/jliSDLmcWmMn 2M0zNj0x9QVxZo5af3R415Yg4or796Ub4uU+Kvwq5PqD9uYopZgs3NLe2vpxDcJ1pSga HAvMht/JLOQnJZjjd/XbnXNrQzQ/Qdrbf/LUQso3RHVToURZy3yvnRb2kSItE9+vKVWM dgN6541Q8QefwOf93PuyFfp1DEO469+rfuRAi73qmNpubwpdgAsLI5+1w12uWi4hTDkQ 624g== X-Gm-Message-State: AOJu0YwVTmlelT+1zUz+wPodzrrwsaJbyiUKMr/WoiKPr9ZVOlLjd9W+ TCik/jbBppk2SsHU1M4w8/ccaWmG8RWo7dNTfVfCp1uUZYZUsbkJG13qQg== X-Google-Smtp-Source: AGHT+IHuxknu4feljVoSfNbnzgl/5Be6s9TeaT9rfO2Yx6ptbE5qMvFr592RlcVTRfiyW2iia7fO0A== X-Received: by 2002:a05:6512:3128:b0:522:33cd:64bd with SMTP id 2adb3069b0e04-52964aba466mr6147647e87.27.1716833429079; Mon, 27 May 2024 11:10:29 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-579c004108esm3346180a12.23.2024.05.27.11.10.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2024 11:10:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function In-Reply-To: Date: Mon, 27 May 2024 20:10:17 +0200 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <43619F54-863D-4D6F-B507-B6256058F4B0@gmail.com> References: To: "Gina P. Banyard" X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) > Le 8 mai 2024 =C3=A0 15:40, Gina P. Banyard a = =C3=A9crit : >=20 > Hello Internals, >=20 > I would like to formally propose my idea for exit() as a function = brought up to the list on 2024-02-24 [1] with the following RFC: > https://wiki.php.net/rfc/exit-as-function >=20 > There have been some slight tweaks to the implementation, namely that = the transformation from a "constant" to a function is done at compile = time and we do not hook into the behaviour of constants any longer. >=20 > Let me know what you think. >=20 > Best regards, >=20 > Gina P. Banyard >=20 > [1] https://externals.io/message/122483 Hi Gina, It is ok, for `exit` to be wired to a function. However, the paren-less = `exit` syntax is absolutely reasonable and should be kept in the long = term (more on this below). It is true that your proposal doesn=E2=80=99t = remove the paren-less form, but the implementation (a hack around = constant evaluation) strongly suggests that it is desirable to deprecate = it in the future (hey, it is even the very first item of the `Future = scope` section). Therefore, I think it is preferable to keep proper = parsing rules for `exit`. Now here is why I think that `exit` syntax without parentheses is = reasonable. For me, `exit` is a control-flow instruction, saying to = terminate the program, just like `return` terminates a function or = `break` terminates a loop. I don=E2=80=99t care about implementation = details, whether it is implemented as invoking a never-returning = function, or as throwing a hidden exception, or whatever. The fact is, = in typical use: ```php header("Location: /somewhere/else.php"); exit; ``` I would consider an oddity and useless noise to put empty parentheses = after a bare `exit`, just as I wouldn=E2=80=99t consider to put empty = parentheses after a bare `return`. (BTW... I wouldn=E2=80=99t describe a bare `yield` (equivalent to `yield = null`) as =E2=80=9Cconstant=E2=80=9D evaluation, even if it may be found = in same positions as a =E2=80=9Creal=E2=80=9D constant.) =E2=80=94Claude=