Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109599 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6301 invoked from network); 12 Apr 2020 21:47:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Apr 2020 21:47:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 884361804CC for ; Sun, 12 Apr 2020 13:16:16 -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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 12 Apr 2020 13:16:15 -0700 (PDT) Received: by mail-yb1-f177.google.com with SMTP id f13so2524032ybk.7 for ; Sun, 12 Apr 2020 13:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=LdlHLuNe6UfO6LP/7Qt8TLPxQJZBYeOhstCivClZAPc=; b=vYVmPXynTpQ5VJxG1qsa4hvjq1X5Fsu8OolrhRU030BAJu8dgvNVcuKBxGcLVU9I1+ IcHQD2V8Y5NjNA5isXAOQyEhS3HFFZGyVvSDrjQVV3Wv497pITgmBwgol7GpkVeWTsk2 8AS6dZ3y0q+0a0NQ1YkKyxbvWbMLPXzA/0fXuXbmxjgYU0kiloCtTSIAj3gt7gbMTzNY vyvRIJS98jxC8ZVVlDSgNWVkPr+TMbeU6GpplQYMUsiiXK1ljepWym0UQ/cM/v2amWns iJzt3IL4ThldnSYU4McEwlwAFHdUBnO9UWZFnRKdNqx+6G0h2cqhtvnXgidTz2sr7Rvw cAdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=LdlHLuNe6UfO6LP/7Qt8TLPxQJZBYeOhstCivClZAPc=; b=M/5IUzfWtQfhiozYYV13yq8qUJv1i/CabWpFYq/JhHvC0Zob9x92KeHDTyJUZtekaQ qu7HC7KREReIEtGRr2jX+8U3dn860kNyPRhP4B5Qk6gVm0sZoMniCwUWyy6LhoHKF3KA 6EQVsHPRbuRUTWFTNZfvGPbJWL+jguIHKZweACDOtEZm5x1HG5Rdsc5pgvZN8FEFzIKj r7EUSF6anvjYWiGrRD00u8+D4kQ88WtNl4j2C/z12SEnqDwFRXhEvI4dpkayZCxObuXN lR9/C9+AAFrjR64gBKBTVC/96F5fF1ZhXgBQ0kJMO6ftD8yOX+vjre6TDn18vgO7ES4o GPpQ== X-Gm-Message-State: AGi0PuYw3DLGATUn37hYJ6z7O2iefxHYvPpafWNt0w41RJ770+WaVBHq Fe5zbS1aGQrQEwa0Yhj5Zf/jzUmb1jLdbiVIfpFriQqU X-Google-Smtp-Source: APiQypIbkiHrFyEcBbxhPZsw0YlG3kd4n5WELvMO9T5i9FgTHyDIIw9p1EmCVcFkGJViO6tzW+LzeG3ROfdyTzCRoeA= X-Received: by 2002:a5b:850:: with SMTP id v16mr3575906ybq.347.1586722574163; Sun, 12 Apr 2020 13:16:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 12 Apr 2020 22:16:02 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [DISCUSSION] Match expression From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Rowan > Can match arms contain other flow control, such as "return" or "continue"? Yes and yes. They behave exactly the same as in the switch. This should definitely be described in the RFC. > Can I mix a bare value and a block as arms of the same match, or does the whole construct need to be in either "expression form" or "statement form"? Yes, you can mix blocks and expressions given you don't use the return value of the whole match expression. > Can I omit the trailing semicolon even in "expression form" Yes. To clarify what's going on here: There's no statement variant of the match expression. PHP already allows using any expression as a statement. https://github.com/php/php-src/blob/422c8390a01ce9b6f612e0183bd0e4500c0608be/Zend/zend_language_parser.y#L446 That's why you can do something like `10 + 20;`. PHP will just discard the result value. The same thing is happening here. The only difference is that I added a rule to the grammar to allow dropping the semicolon in this case because I noticed that I kept forgetting to add it in my tests. > We can always add statement blocks in later I think we'll never completely agree on this point, and that's fine. As mentioned in my announcement IMO it doesn't make sense criticizing the switch statement but then not offering an alternative. Thanks for your input! Ilija