Re: Proposal For Return-If / Early Return / Guard Clause Syntax
| From: | David Rodrigues | Date: | Sun, 10 May 2020 21:33:32 +0000 |
| Subject: | Re: Proposal For Return-If / Early Return / Guard Clause Syntax | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110119@lists.php.net to get a copy of this message | ||
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
>