Re: [PHP-DEV] Proposal For Return-If / Early Return / Guard ClauseSyntax

This is only part of a thread. view whole thread
  110116
May 10, 2020 19:59 ralph@ralphschindler.com (Ralph Schindler)
On 5/10/20 1:56 PM, David Rodrigues wrote:
> Suggestion: > > return if $x > 1; (to return "void") > return $y if ($x > 1 && $x < 5); > break if $x > 1; > break 2 if $x > 1; > throw new Exception if $x > 1; >
100% that will/should be a votable alternative option should this get to the voting phase. I have reasons for why I chose my initial path, but its worth mentioning I favor the optional value at the end maybe 65% to 35% where the value is after the initial keyword. Thanks for taking the time! -ralph schindler
  110119
May 10, 2020 21:33 david.proweb@gmail.com (David Rodrigues)
I just think that this way is more compatible witth the reading. "Return X
if Y" seems better than "return (if) X: (then) Y". Too the ":" could
conflicts with return type.

Em dom, 10 de mai de 2020 16:59, Ralph Schindler <ralph@ralphschindler.com>
escreveu:

> > > On 5/10/20 1:56 PM, David Rodrigues wrote: > > Suggestion: > > > > return if $x > 1; (to return "void") > > return $y if ($x > 1 && $x < 5); > > break if $x > 1; > > break 2 if $x > 1; > > throw new Exception if $x > 1; > > > > 100% that will/should be a votable alternative option should this get to > the voting phase. > > I have reasons for why I chose my initial path, but its worth mentioning > I favor the optional value at the end maybe 65% to 35% where the value > is after the initial keyword. > > Thanks for taking the time! > -ralph schindler >