Re: [RFC] Guard statement

From: Date: Sat, 16 May 2020 14:15:53 +0000
Subject: Re: [RFC] Guard statement
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-110182@lists.php.net to get a copy of this message
On Sat, May 16, 2020 at 11:14 AM Pavel Patapau <algerd.blr@gmail.com> wrote: > > Hello everyone, > > I want to propose new syntax addition - guard statement, that executes > code only if expression equals false and must contain control-flow > changing code, and written a respective RFC: > > https://wiki.php.net/rfc/guard_statement > <https://wiki.php.net/rfc/unbundle_xmlprc> > > Implementation in progress. > > I started work before this proposal > https://externals.io/message/110107 > and respected some moments in the RFC. > > > Thanks for consideration, > Pavel > Hi Pavel, My feeling about this is that simply adding the "guard" keyword to be able to write an "negated if" and further requiring certain stuff to be found in the body statement (which does not sounds trivial) is not worth the added weight. I found the inverse "if" construct (return/break/continue/exit/throw [...] if [...]) that was discussed in the thread as well to be more interesting, potentially adding something new and flavourful to the language. However, since I am very much opposed to methods with multiple return statements, I would probably only use it in the throw version for defensive programming. Best, Jakob

« previous php.internals (#110182) next »