Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110182 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14306 invoked from network); 16 May 2020 15:38:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 May 2020 15:38:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 64E341804FD for ; Sat, 16 May 2020 07:16:07 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS48854 94.231.96.0/20 X-Spam-Virus: No X-Envelope-From: Received: from smtp.simply.com (smtp.simply.com [94.231.106.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 16 May 2020 07:16:06 -0700 (PDT) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp.simply.com (Simply.com) with ESMTPSA id 49PS4N1jBCz63HZ for ; Sat, 16 May 2020 16:16:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=givoni.dk; s=unoeuro; t=1589638564; bh=geWAL6BLU/Nar6Oeolw0a3Wz5yYidyRXLaJm1tI77uA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=b4uLFtrQ5Kun/PlQhIVY89rWoBeO6RfC1Y4dIRzwxUiAN9Lojudf79JCJsKNrecm1 GzKZYo6lZDt/slMlvkzlaxZZKUCoHc9rBrVRg6n4hzNH/WSLac3A6Hg8So0hr7IXpJ dnCqOWCVa1nyVlRSFTQO05SgzxeQfIi0fVjCPeVQ= Received: by mail-wm1-f50.google.com with SMTP id w64so5506141wmg.4 for ; Sat, 16 May 2020 07:16:04 -0700 (PDT) X-Gm-Message-State: AOAM5324GYEkwufgD9bDJWp7kAW5IShC8iAunFEX8BLbomNGkRl9mPlu wJDj+4Pe9mTlqI7fhBrLYJiGqc0X3/pjG2jCyWU= X-Google-Smtp-Source: ABdhPJzmHg1MfNtA1ijX0qrJQ9uTd8h0xd5c+2DDhxuzu7yhruO5WKJenLmMuk750HHO0r9at23Pg6F0R6xFAFLdXXA= X-Received: by 2002:a7b:c62a:: with SMTP id p10mr8870231wmk.143.1589638563847; Sat, 16 May 2020 07:16:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 16 May 2020 16:15:53 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Pavel Patapau Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Guard statement From: jakob@givoni.dk (Jakob Givoni) On Sat, May 16, 2020 at 11:14 AM Pavel Patapau 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 > > > 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