Re: [Pre-RFC] Convert exit (and die) from language constructs to functions

From: Date: Sun, 25 Feb 2024 22:07:11 +0000
Subject: Re: [Pre-RFC] Convert exit (and die) from language constructs to functions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122528@lists.php.net to get a copy of this message
> > I hear you, but what about exit; ?! > Do not worry exit; is still supported! > It only requires a _tiny_ bit of dark magic to achieve this! > exit; would just be interpreted as a fetch to a constant, > so when attempting to access the undefined exit/die case-insensitive constant > we just need to exit as if we were calling the function! > Hi Gina, If it is mostly an implementation detail, this is probably ok. However, please make sure that $foo = 'exit'; constant($foo); (or any other future way to interpolate the constant) does not stop the program, but only fetch the value of a “real” constant. Alternatively, it is probably possible to keep the current parsing with T_EXIT, but to make it equivalent to invoke a “regular” function named exit() — somehow the same way that using the backtick operator is equivalent to calling shell_exec(), up to the point that disabling shell_exec() will also disable the the backtick operator? (BTW, it *is* currently possible to define and use a constant named “exit”: https://3v4l.org/aBq2R — of course, no need to keep such a “feature”.) —Claude

« previous php.internals (#122528) next »