On 10/03/2021 18:06, Matthew Brown wrote:
Ondřej Mirtes and I present an RFC for the noreturn type:
https://wiki.php.net/rfc/noreturn_type


Thanks for the proposal, I can certainly think of uses for it.


I am however slightly confused by what exactly the implementation checks, and when. Is it actually looking for "exit" and "throw" statements?

The text talks about exiting "explicitly or implicitly", but doesn't give any examples of how this works. For instance, is this code valid, and how does PHP know that it's valid?

function my_exit(string $reason): noreturn {
    exit("$reason\n");
}
function canned_exit(): noreturn {
   my_exit("The normal reason");
}


The other thing I'd like to mention is that PHP's implementation of "void" consists mostly of checking that there is no return statement, so a separate keyword of "noreturn" may well cause confusion. I would personally prefer the name "never" for this reason.


Regards,

--
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to